PMDK C++ bindings
1.7
This is the C++ bindings documentation for PMDK's libpmemobj.
|
C++ automatic scope transaction class. More...
#include <libpmemobj++/transaction.hpp>
Classes | |
class | uncaught_exception_counter |
Internal class for counting active exceptions. More... | |
Public Member Functions | |
template<typename... L> | |
automatic (obj::pool_base &pop, L &... locks) | |
RAII constructor with pmem resident locks. More... | |
~automatic () noexcept(false) | |
Destructor. More... | |
automatic (const automatic &p)=delete | |
Deleted copy constructor. | |
automatic (const automatic &&p)=delete | |
Deleted move constructor. | |
automatic & | operator= (const automatic &p)=delete |
Deleted assignment operator. | |
automatic & | operator= (automatic &&p)=delete |
Deleted move assignment operator. | |
C++ automatic scope transaction class.
This class is one of pmemobj transaction handlers. All operations between creating and destroying the transaction object are treated as performed in a transaction block and can be rolled back. If you have a C++17 compliant compiler, the automatic transaction will commit and abort automatically depending on the context of object destruction.
The locks are held for the entire duration of the transaction. They are released at the end of the scope, so within the catch
block, they are already unlocked. If the cleanup action requires access to data within a critical section, the locks have to be manually acquired once again.
The typical usage example would be:
|
inline |
RAII constructor with pmem resident locks.
Start pmemobj transaction and add list of locks to new transaction. The list of locks may be empty.
This class is only available if the __cpp_lib_uncaught_exceptions
feature macro is defined. This is a C++17 feature.
[in,out] | pop | pool object. |
[in,out] | locks | locks of obj::mutex or obj::shared_mutex type. |
pmem::transaction_error | when pmemobj_tx_begin function or locks adding failed. |
|
inlinenoexcept |
Destructor.
End pmemobj transaction. Depending on the context of object destruction, the transaction will automatically be either committed or aborted.
pmem::transaction_error | if the transaction got aborted without an active exception. |