PMDK C++ bindings
1.5.2
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Go to the documentation of this file.
38 #ifndef LIBPMEMOBJ_CPP_TRANSACTION_HPP
39 #define LIBPMEMOBJ_CPP_TRANSACTION_HPP
47 #include <libpmemobj/tx_base.h>
107 template <
typename... L>
110 if (pmemobj_tx_begin(pop.handle(),
nullptr,
113 "failed to start transaction");
118 pmemobj_tx_abort(EINVAL);
119 (void)pmemobj_tx_end();
135 if (pmemobj_tx_stage() == TX_STAGE_WORK)
136 pmemobj_tx_abort(ECANCELED);
138 (void)pmemobj_tx_end();
166 #if __cpp_lib_uncaught_exceptions || _MSC_VER >= 1900
205 template <
typename... L>
207 : tx_worker(pop, locks...)
228 if (pmemobj_tx_stage() == TX_STAGE_WORK)
231 else if (pmemobj_tx_stage() == TX_STAGE_ONABORT ||
232 (pmemobj_tx_stage() == TX_STAGE_FINALLY &&
233 pmemobj_tx_errno() != 0))
270 :
count(std::uncaught_exceptions())
284 return std::uncaught_exceptions() > this->
count;
328 if (pmemobj_tx_stage() != TX_STAGE_WORK)
332 pmemobj_tx_abort(err);
349 if (pmemobj_tx_stage() != TX_STAGE_WORK)
359 return pmemobj_tx_errno();
362 POBJ_CPP_DEPRECATED
static int
363 get_last_tx_error() noexcept
365 return transaction::error();
399 template <
typename... Locks>
403 if (pmemobj_tx_begin(
pool.handle(),
nullptr, TX_PARAM_NONE) !=
410 pmemobj_tx_abort(err);
411 (void)pmemobj_tx_end();
419 (void)pmemobj_tx_end();
423 if (pmemobj_tx_stage() == TX_STAGE_WORK)
424 pmemobj_tx_abort(ECANCELED);
427 (void)pmemobj_tx_end();
431 auto stage = pmemobj_tx_stage();
433 if (stage == TX_STAGE_WORK) {
435 }
else if (stage == TX_STAGE_ONABORT) {
436 (void)pmemobj_tx_end();
438 }
else if (stage == TX_STAGE_NONE) {
443 (void)pmemobj_tx_end();
446 template <
typename... Locks>
447 POBJ_CPP_DEPRECATED
static void
448 exec_tx(
pool_base &
pool, std::function<
void()> tx, Locks &... locks)
466 template <
typename L,
typename... Locks>
471 pmemobj_tx_lock(lock.lock_type(), lock.native_handle());
automatic(obj::pool_base &pop, L &... locks)
RAII constructor with pmem resident locks.
Definition: transaction.hpp:206
int count
The number of active exceptions.
Definition: transaction.hpp:291
static void commit()
Manually commit a transaction.
Definition: transaction.hpp:347
manual & operator=(manual &&p)=delete
Deleted move assignment operator.
Custom transaction error class.
Definition: pexceptions.hpp:63
automatic & operator=(const automatic &p)=delete
Deleted assignment operator.
Commonly used functionality.
static int add_lock(L &lock, Locks &... locks) noexcept
Recursively add locks to the active transaction.
Definition: transaction.hpp:468
~manual() noexcept
Destructor.
Definition: transaction.hpp:132
Resides on pmem class.
Definition: p.hpp:64
manual(obj::pool_base &pop, L &... locks)
RAII constructor with pmem resident locks.
Definition: transaction.hpp:108
static void run(pool_base &pool, std::function< void()> tx, Locks &... locks)
Execute a closure-like transaction and lock locks.
Definition: transaction.hpp:401
static int add_lock() noexcept
Method ending the recursive algorithm.
Definition: transaction.hpp:483
automatic & operator=(automatic &&p)=delete
Deleted move assignment operator.
automatic(const automatic &p)=delete
Deleted copy constructor.
C++ automatic scope transaction class.
Definition: transaction.hpp:186
Internal class for counting active exceptions.
Definition: transaction.hpp:261
bool new_uncaught_exception()
Notifies is a new exception is being handled.
Definition: transaction.hpp:282
uncaught_exception_counter()
Default constructor.
Definition: transaction.hpp:269
PMEMobj pool class.
Definition: pool.hpp:430
manual & operator=(const manual &p)=delete
Deleted assignment operator.
~transaction() noexcept=delete
Default destructor.
~automatic() noexcept(false)
Destructor.
Definition: transaction.hpp:221
manual(const manual &p)=delete
Deleted copy constructor.
C++ transaction handler class.
Definition: transaction.hpp:72
Custom transaction error class.
Definition: pexceptions.hpp:114
The non-template pool base class.
Definition: pool.hpp:66
automatic(const automatic &&p)=delete
Deleted move constructor.
static void abort(int err)
Manually abort the current transaction.
Definition: transaction.hpp:326
C++ manual scope transaction class.
Definition: transaction.hpp:92
manual(const manual &&p)=delete
Deleted move constructor.