2018-01-18 03:14:13 +01:00
|
|
|
// 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
|
2018-01-19 02:59:22 +01:00
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
2018-01-18 03:14:13 +01:00
|
|
|
|
|
|
|
#pragma once
|
2018-01-19 02:59:22 +01:00
|
|
|
#define HAVE_IRCD_DB_DATABASE_SNAPSHOT_H
|
2018-01-18 03:14:13 +01:00
|
|
|
|
2018-01-18 03:34:20 +01:00
|
|
|
// Forward declarations for RocksDB because it is not included here.
|
|
|
|
namespace rocksdb
|
|
|
|
{
|
|
|
|
struct Snapshot;
|
|
|
|
}
|
|
|
|
|
2018-01-18 03:14:13 +01:00
|
|
|
/// 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 &);
|
|
|
|
};
|