9 #ifndef LIBPMEMOBJ_CPP_MUTEX_HPP
10 #define LIBPMEMOBJ_CPP_MUTEX_HPP
13 #include <libpmemobj/thread.h>
14 #include <libpmemobj/tx_base.h>
44 if ((pop = pmemobj_pool_by_ptr(&
plock)) ==
nullptr)
46 1, std::generic_category(),
47 "Persistent mutex not from persistent memory.");
49 pmemobj_mutex_zero(pop, &
plock);
71 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
72 if (
int ret = pmemobj_mutex_lock(pop, &this->
plock))
74 "Failed to lock a mutex.")
75 .with_pmemobj_errormsg();
95 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
96 int ret = pmemobj_mutex_trylock(pop, &this->
plock);
100 else if (ret == EBUSY)
104 "Failed to lock a mutex.")
105 .with_pmemobj_errormsg();
118 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
119 int ret = pmemobj_mutex_unlock(pop, &this->
plock);
122 "Failed to unlock a mutex.")
123 .with_pmemobj_errormsg();
145 return TX_PARAM_MUTEX;