38 #ifndef LIBPMEMOBJ_CPP_SHARED_MUTEX_HPP
39 #define LIBPMEMOBJ_CPP_SHARED_MUTEX_HPP
41 #include <libpmemobj/thread.h>
42 #include <libpmemobj/tx_base.h>
73 if ((pop = pmemobj_pool_by_ptr(&
plock)) ==
nullptr)
75 "Persistent shared mutex not from "
76 "persistent memory.");
78 pmemobj_rwlock_zero(pop, &
plock);
101 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
102 if (
int ret = pmemobj_rwlock_wrlock(pop, &this->
plock))
126 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
127 if (
int ret = pmemobj_rwlock_rdlock(pop, &this->
plock))
129 "Failed to shared lock a "
150 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
151 int ret = pmemobj_rwlock_trywrlock(pop, &this->
plock);
155 else if (ret == EBUSY)
182 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
183 int ret = pmemobj_rwlock_tryrdlock(pop, &this->
plock);
187 else if (ret == EBUSY)
204 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
205 int ret = pmemobj_rwlock_unlock(pop, &this->
plock);
208 "Failed to unlock a shared mutex.");
242 return TX_PARAM_RWLOCK;