38 #ifndef PMEMOBJ_SHARED_MUTEX_HPP 39 #define PMEMOBJ_SHARED_MUTEX_HPP 41 #include "libpmemobj/thread.h" 42 #include "libpmemobj/tx_base.h" 89 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
90 if (
int ret = pmemobj_rwlock_wrlock(pop, &this->
plock))
114 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
115 if (
int ret = pmemobj_rwlock_rdlock(pop, &this->
plock))
117 "Failed to shared lock a " 138 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
139 int ret = pmemobj_rwlock_trywrlock(pop, &this->
plock);
143 else if (ret == EBUSY)
170 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
171 int ret = pmemobj_rwlock_tryrdlock(pop, &this->
plock);
175 else if (ret == EBUSY)
196 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
197 if (
int ret = pmemobj_rwlock_unlock(pop, &this->
plock))
238 return TX_LOCK_RWLOCK;
PMEMrwlock * native_handle_type
Implementation defined handle to the native type.
Definition: shared_mutex.hpp:62
shared_mutex & operator=(const shared_mutex &)=delete
Deleted assignment operator.
native_handle_type native_handle() noexcept
Access a native handle to this shared mutex.
Definition: shared_mutex.hpp:225
bool try_lock_shared()
Try to lock the mutex for shared access, returns regardless if the lock succeeds. ...
Definition: shared_mutex.hpp:168
void unlock_shared()
Unlocks the mutex.
Definition: shared_mutex.hpp:214
void lock()
Lock the mutex for exclusive access.
Definition: shared_mutex.hpp:87
void unlock()
Unlocks the mutex.
Definition: shared_mutex.hpp:194
Custom lock error class.
Definition: pexceptions.hpp:74
enum pobj_tx_lock lock_type() const noexcept
The type of lock needed for the transaction API.
Definition: shared_mutex.hpp:236
bool try_lock()
Try to lock the mutex for exclusive access, returns regardless if the lock succeeds.
Definition: shared_mutex.hpp:136
void lock_shared()
Lock the mutex for shared access.
Definition: shared_mutex.hpp:112
Definition: condition_variable.hpp:48
Persistent memory resident shared_mutex implementation.
Definition: shared_mutex.hpp:59
shared_mutex() noexcept=default
Defaulted constructor.
PMEMrwlock plock
A POSIX style PMEM-resident shared_mutex.
Definition: shared_mutex.hpp:253