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);
164 #if __cpp_lib_uncaught_exceptions || _MSC_VER >= 1900 203 template <
typename... L>
206 if (pmemobj_tx_begin(pop.get_handle(), NULL,
209 "failed to start transaction");
214 pmemobj_tx_abort(EINVAL);
230 if (pmemobj_tx_stage() != TX_STAGE_WORK) {
235 if (this->exceptions.new_uncaught_exception())
237 pmemobj_tx_abort(ECANCELED);
278 : count(std::uncaught_exceptions())
292 return std::uncaught_exceptions() > this->count;
334 if (pmemobj_tx_stage() != TX_STAGE_WORK)
338 pmemobj_tx_abort(err);
355 if (pmemobj_tx_stage() != TX_STAGE_WORK)
363 get_last_tx_error() noexcept
365 return pmemobj_tx_errno();
399 template <
typename... Locks>
403 if (pmemobj_tx_begin(pool.get_handle(), NULL, TX_LOCK_NONE) !=
410 pmemobj_tx_abort(err);
423 if (pmemobj_tx_stage() == TX_STAGE_WORK)
424 pmemobj_tx_abort(ECANCELED);
431 auto stage = pmemobj_tx_stage();
433 if (stage == TX_STAGE_WORK) {
435 }
else if (stage == TX_STAGE_ONABORT) {
438 }
else if (stage == TX_STAGE_NONE) {
459 template <
typename L,
typename... Locks>
464 pmemobj_tx_lock(lock.lock_type(), lock.native_handle());
static int add_lock(L &lock, Locks &...locks) noexcept
Recursively add locks to the active transaction.
Definition: transaction.hpp:461
C++ automatic scope transaction class.
Definition: transaction.hpp:184
static int add_lock() noexcept
Method ending the recursive algorithm.
Definition: transaction.hpp:476
static void abort(int err)
Manually abort the current transaction.
Definition: transaction.hpp:332
Internal class for counting active exceptions.
Definition: transaction.hpp:269
manual & operator=(const manual &p)=delete
Deleted assignment operator.
The non-template pool base class.
Definition: pool.hpp:64
bool new_uncaught_exception()
Notifies is a new exception is being handled.
Definition: transaction.hpp:290
Custom transaction error class.
Definition: pexceptions.hpp:104
manual(obj::pool_base &pop, L &...locks)
RAII constructor with pmem resident locks.
Definition: transaction.hpp:107
Custom transaction error class.
Definition: pexceptions.hpp:63
~transaction() noexcept=delete
Default destructor.
~automatic() noexcept
Destructor.
Definition: transaction.hpp:227
PMEMobj pool class.
Definition: persistent_ptr.hpp:55
C++ manual scope transaction class.
Definition: transaction.hpp:91
int count
The number of active exceptions.
Definition: transaction.hpp:299
Resides on pmem class.
Definition: p.hpp:64
static void exec_tx(pool_base &pool, std::function< void()> tx, Locks &...locks)
Execute a closure-like transaction and lock locks.
Definition: transaction.hpp:401
automatic(obj::pool_base &pop, L &...locks)
RAII constructor with pmem resident locks.
Definition: transaction.hpp:204
Definition: condition_variable.hpp:48
~manual() noexcept
Destructor.
Definition: transaction.hpp:130
C++ transaction handler class.
Definition: transaction.hpp:71
uncaught_exception_counter()
Default constructor.
Definition: transaction.hpp:277
static void commit()
Manually commit a transaction.
Definition: transaction.hpp:353