From 591e0cae68e8f687b312c90d17d0c2d1b44c894c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Mon, 4 Nov 2024 11:44:20 +0100 Subject: [PATCH] Release guard after transaction --- nano/secure/transaction.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/nano/secure/transaction.hpp b/nano/secure/transaction.hpp index 6c4acde3d3..8a3ebd9c1d 100644 --- a/nano/secure/transaction.hpp +++ b/nano/secure/transaction.hpp @@ -29,17 +29,18 @@ class transaction virtual operator const nano::store::transaction & () const = 0; }; -class write_transaction : public transaction +class write_transaction final : public transaction { + nano::store::write_guard guard; // Guard should be released after the transaction nano::store::write_transaction txn; - nano::store::write_guard guard; std::chrono::steady_clock::time_point start; public: - explicit write_transaction (nano::store::write_transaction && txn, nano::store::write_guard && guard) noexcept : - txn{ std::move (txn) }, - guard{ std::move (guard) } + explicit write_transaction (nano::store::write_transaction && txn_a, nano::store::write_guard && guard_a) noexcept : + guard{ std::move (guard_a) }, + txn{ std::move (txn_a) } { + debug_assert (guard.is_owned ()); start = std::chrono::steady_clock::now (); } @@ -97,7 +98,7 @@ class write_transaction : public transaction } }; -class read_transaction : public transaction +class read_transaction final : public transaction { nano::store::read_transaction txn; @@ -140,4 +141,4 @@ class read_transaction : public transaction return txn; } }; -} // namespace nano::secure +}