Skip to content

Commit

Permalink
Release guard after transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Nov 4, 2024
1 parent a6d7d1c commit 591e0ca
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions nano/secure/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
}

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -140,4 +141,4 @@ class read_transaction : public transaction
return txn;
}
};
} // namespace nano::secure
}

0 comments on commit 591e0ca

Please sign in to comment.