38 #ifndef LIBPMEMOBJ_CPP_MUTEX_HPP
39 #define LIBPMEMOBJ_CPP_MUTEX_HPP
42 #include <libpmemobj/thread.h>
43 #include <libpmemobj/tx_base.h>
73 if ((pop = pmemobj_pool_by_ptr(&
plock)) ==
nullptr)
75 1, std::generic_category(),
76 "Persistent mutex not from persistent memory.");
78 pmemobj_mutex_zero(pop, &
plock);
100 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
101 if (
int ret = pmemobj_mutex_lock(pop, &this->
plock))
103 "Failed to lock a mutex.");
123 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
124 int ret = pmemobj_mutex_trylock(pop, &this->
plock);
128 else if (ret == EBUSY)
132 "Failed to lock a mutex.");
145 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
146 int ret = pmemobj_mutex_unlock(pop, &this->
plock);
149 "Failed to unlock a mutex.");
171 return TX_PARAM_MUTEX;