33 #include <type_traits>
70 MDB_env* handle()
const noexcept {
return env.get(); }
115 for (
unsigned i = 0; i < attempts; ++i)
122 const auto wrote = f(*(*txn));
std::error_code error() const noexcept
Manages a LMDB environment for safe memory-map resizing. Thread-safe.
database(database const &)=delete
expect< suspended_txn > reset_txn(read_txn txn) noexcept
expect< void > commit(write_txn txn) noexcept
Commit the read-write transaction.
expect< write_txn > create_write_txn() noexcept
database(database &&)=delete
expect< void > resize() noexcept
virtual ~database() noexcept
expect< read_txn > create_read_txn(suspended_txn txn=nullptr) noexcept
database(environment env)
std::result_of< F(MDB_txn &)>::type try_write(F f, unsigned attempts=3)
#define ELECTRONEUM_PRECOND(...)
If precondition fails, return ::error::kInvalidArgument in current scope.
#define ELECTRONEUM_CHECK(...)
Check expect<void> and return errors in current scope.
void mdb_env_close(MDB_env *env)
Close the environment and release the memory map.
struct MDB_env MDB_env
Opaque structure for a database environment.
struct MDB_txn MDB_txn
Opaque structure for a transaction handle.
unsigned int MDB_dbi
A handle for an individual database in the DB environment.
std::unique_ptr< MDB_txn, abort_txn > suspended_txn
std::unique_ptr< MDB_env, close_env > environment
std::unique_ptr< MDB_txn, release_read_txn > read_txn
std::unique_ptr< MDB_txn, abort_write_txn > write_txn
error
Tracks LMDB error codes.
expect< environment > open_environment(const char *path, MDB_dbi max_dbs) noexcept
const T & move(const T &t)
Closes LMDB environment handle.
void operator()(MDB_env *ptr) const noexcept
std::atomic< std::size_t > active