0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-04 21:08:57 +01:00
construct/include/ircd/db/snapshot.h

43 lines
1.4 KiB
C
Raw Normal View History

// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2019 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;
}
2019-02-16 01:47:00 +01:00
namespace ircd::db
{
uint64_t sequence(const database::snapshot &); // Sequence of a snapshot
uint64_t sequence(const rocksdb::Snapshot *const &);
}
/// 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;
};