0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-30 18:39:02 +01:00
construct/include/ircd/db/database/snapshot.h

40 lines
1.4 KiB
C
Raw Normal View History

// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#pragma once
#define HAVE_IRCD_DB_DATABASE_SNAPSHOT_H
// Forward declarations for RocksDB because it is not included here.
namespace rocksdb
{
struct Snapshot;
}
/// Database snapshot object. Maintaining this object will maintain a
/// consistent state of access to the database at the sequence number
/// from when it's acquired.
struct ircd::db::database::snapshot
{
std::shared_ptr<const rocksdb::Snapshot> s;
public:
operator const rocksdb::Snapshot *() const { return s.get(); }
explicit operator bool() const { return bool(s); }
bool operator !() const { return !s; }
explicit snapshot(database &);
snapshot() = default;
~snapshot() noexcept;
friend uint64_t sequence(const snapshot &); // Sequence of a snapshot
friend uint64_t sequence(const rocksdb::Snapshot *const &);
};