38 #ifndef LIBPMEMOBJ_TRANSACTION_HPP 39 #define LIBPMEMOBJ_TRANSACTION_HPP 46 #include "libpmemobj/tx_base.h" 106 template <
typename... L>
109 if (pmemobj_tx_begin(pop.get_handle(), NULL,
112 "failed to start transaction");
117 pmemobj_tx_abort(EINVAL);
133 if (pmemobj_tx_stage() == TX_STAGE_WORK)
134 pmemobj_tx_abort(ECANCELED);
136 (void)pmemobj_tx_end();
164 #if __cpp_lib_uncaught_exceptions || _MSC_VER >= 1900 203 template <
typename... L>
205 : tx_worker(pop, locks...)
226 if (pmemobj_tx_stage() == TX_STAGE_WORK)
229 else if (pmemobj_tx_stage() == TX_STAGE_ONABORT ||
230 (pmemobj_tx_stage() == TX_STAGE_FINALLY &&
231 pmemobj_tx_errno() != 0))
282 return std::uncaught_exceptions() > this->
count;
326 if (pmemobj_tx_stage() != TX_STAGE_WORK)
330 pmemobj_tx_abort(err);
347 if (pmemobj_tx_stage() != TX_STAGE_WORK)
355 get_last_tx_error() noexcept
357 return pmemobj_tx_errno();
391 template <
typename... Locks>
395 if (pmemobj_tx_begin(
pool.get_handle(), NULL, TX_PARAM_NONE) !=
402 pmemobj_tx_abort(err);
403 (void)pmemobj_tx_end();
411 (void)pmemobj_tx_end();
415 if (pmemobj_tx_stage() == TX_STAGE_WORK)
416 pmemobj_tx_abort(ECANCELED);
419 (void)pmemobj_tx_end();
423 auto stage = pmemobj_tx_stage();
425 if (stage == TX_STAGE_WORK) {
427 }
else if (stage == TX_STAGE_ONABORT) {
428 (void)pmemobj_tx_end();
430 }
else if (stage == TX_STAGE_NONE) {
435 (void)pmemobj_tx_end();
451 template <
typename L,
typename... Locks>
456 pmemobj_tx_lock(lock.lock_type(), lock.native_handle());
int count
The number of active exceptions.
Definition: transaction.hpp:289
static int add_lock() noexcept
Method ending the recursive algorithm.
Definition: transaction.hpp:468
The non-template pool base class.
Definition: pool.hpp:65
Internal class for counting active exceptions.
Definition: transaction.hpp:259
~manual() noexcept
Destructor.
Definition: transaction.hpp:130
~automatic() noexcept(false)
Destructor.
Definition: transaction.hpp:219
C++ transaction handler class.
Definition: transaction.hpp:71
Custom transaction error class.
Definition: pexceptions.hpp:114
C++ manual scope transaction class.
Definition: transaction.hpp:91
PMEMobj pool class.
Definition: persistent_ptr.hpp:59
manual & operator=(const manual &p)=delete
Deleted assignment operator.
static void exec_tx(pool_base &pool, std::function< void()> tx, Locks &... locks)
Execute a closure-like transaction and lock locks.
Definition: transaction.hpp:393
manual(obj::pool_base &pop, L &... locks)
RAII constructor with pmem resident locks.
Definition: transaction.hpp:107
static void commit()
Manually commit a transaction.
Definition: transaction.hpp:345
static void abort(int err)
Manually abort the current transaction.
Definition: transaction.hpp:324
~transaction() noexcept=delete
Default destructor.
C++ automatic scope transaction class.
Definition: transaction.hpp:184
Custom transaction error class.
Definition: pexceptions.hpp:63
static int add_lock(L &lock, Locks &... locks) noexcept
Recursively add locks to the active transaction.
Definition: transaction.hpp:453
bool new_uncaught_exception()
Notifies is a new exception is being handled.
Definition: transaction.hpp:280
automatic(obj::pool_base &pop, L &... locks)
RAII constructor with pmem resident locks.
Definition: transaction.hpp:204
uncaught_exception_counter()
Default constructor.
Definition: transaction.hpp:267
Resides on pmem class.
Definition: p.hpp:64
Definition: allocator.hpp:48
automatic & operator=(const automatic &p)=delete
Deleted assignment operator.