From 55142d8d6f3a1b5649241872da6af4a9ec7f00cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Tue, 21 Nov 2023 15:17:07 +0300 Subject: [PATCH] =?UTF-8?q?mdbx++:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20`txn::commit=5Fembark=5Fread()`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mdbx.h++ | 4 ++++ src/mdbx.c++ | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/mdbx.h++ b/mdbx.h++ index e8614e41..27df86de 100644 --- a/mdbx.h++ +++ b/mdbx.h++ @@ -4318,6 +4318,10 @@ public: /// \brief Commit all the operations of a transaction into the database. void commit(); + /// \brief Commit all the operations of a transaction into the database + /// and then start read transaction. + void commit_embark_read(); + using commit_latency = MDBX_commit_latency; /// \brief Commit all the operations of a transaction into the database diff --git a/src/mdbx.c++ b/src/mdbx.c++ index 4381b8e8..621c2695 100644 --- a/src/mdbx.c++ +++ b/src/mdbx.c++ @@ -1555,6 +1555,13 @@ void txn_managed::commit(commit_latency *latency) { MDBX_CXX20_UNLIKELY err.throw_exception(); } +void txn_managed::commit_embark_read() { + auto env = this->env(); + commit(); + error::success_or_throw( + ::mdbx_txn_begin(env, nullptr, MDBX_TXN_RDONLY, &handle_)); +} + //------------------------------------------------------------------------------ bool txn::drop_map(const char *name, bool throw_if_absent) {