From bee7431f76dc9aa21415fb9e88aa241920f841ae 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: Thu, 6 Oct 2022 23:47:16 +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=B0=20=D1=84=D0=B8=D0=BA=D1=81=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20=D1=82=D1=80=D0=B0=D0=BD=D0=B7=D0=B0=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D1=81=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=D0=BC=20=D0=B8=D0=BD=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D0=BE=20=D0=B7=D0=B0=D0=B4=D0=B5=D1=80?= =?UTF-8?q?=D0=B6=D0=BA=D0=B0=D1=85.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mdbx.h++ | 23 +++++++++++++++++++++-- src/mdbx.c++ | 9 +++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/mdbx.h++ b/mdbx.h++ index 623b4cc2..473def91 100644 --- a/mdbx.h++ +++ b/mdbx.h++ @@ -3875,12 +3875,31 @@ public: //---------------------------------------------------------------------------- - /// \brief Abandon all the operations of the transaction instead of saving - /// them. + /// \brief Abandon all the operations of the transaction + /// instead of saving ones. void abort(); /// \brief Commit all the operations of a transaction into the database. void commit(); + + using commit_latency = MDBX_commit_latency; + + /// \brief Commit all the operations of a transaction into the database + /// and collect latency information. + void commit(commit_latency *); + + /// \brief Commit all the operations of a transaction into the database + /// and collect latency information. + void commit(commit_latency &latency) { return commit(&latency); } + + /// \brief Commit all the operations of a transaction into the database + /// and return latency information. + /// \returns latency information of commit stages. + commit_latency commit_get_latency() { + commit_latency result; + commit(&result); + return result; + } }; /// \brief Unmanaged cursor. diff --git a/src/mdbx.c++ b/src/mdbx.c++ index 4be94939..78a4ead0 100644 --- a/src/mdbx.c++ +++ b/src/mdbx.c++ @@ -1424,6 +1424,15 @@ void txn_managed::commit() { MDBX_CXX20_UNLIKELY err.throw_exception(); } +void txn_managed::commit(commit_latency *latency) { + const error err = + static_cast(::mdbx_txn_commit_ex(handle_, latency)); + if (MDBX_LIKELY(err.code() != MDBX_THREAD_MISMATCH)) + MDBX_CXX20_LIKELY handle_ = nullptr; + if (MDBX_UNLIKELY(err.code() != MDBX_SUCCESS)) + MDBX_CXX20_UNLIKELY err.throw_exception(); +} + //------------------------------------------------------------------------------ bool txn::drop_map(const char *name, bool throw_if_absent) {