38 #ifndef PMEMOBJ_MUTEX_HPP 39 #define PMEMOBJ_MUTEX_HPP 42 #include "libpmemobj/thread.h" 43 #include "libpmemobj/tx_base.h" 68 mutex() noexcept = default;
89 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
90 if (
int ret = pmemobj_mutex_lock(pop, &this->
plock))
92 "Failed to lock a mutex.");
112 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
113 int ret = pmemobj_mutex_trylock(pop, &this->
plock);
117 else if (ret == EBUSY)
121 "Failed to lock a mutex.");
138 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
139 if (
int ret = pmemobj_mutex_unlock(pop, &this->
plock))
141 "Failed to unlock a mutex.");
163 return TX_LOCK_MUTEX;
mutex & operator=(const mutex &)=delete
Deleted assignment operator.
PMEMmutex * native_handle_type
Implementation defined handle to the native type.
Definition: mutex.hpp:63
native_handle_type native_handle() noexcept
Access a native handle to this condition variable.
Definition: mutex.hpp:150
mutex() noexcept=default
Defaulted constructor.
Persistent memory resident mutex implementation.
Definition: mutex.hpp:60
bool try_lock()
Tries to lock the mutex, returns regardless if the lock succeeds.
Definition: mutex.hpp:110
void lock()
Locks the mutex, blocks if already locked.
Definition: mutex.hpp:87
Custom lock error class.
Definition: pexceptions.hpp:74
Definition: condition_variable.hpp:48
PMEMmutex plock
A POSIX style PMEM-resident mutex.
Definition: mutex.hpp:178
enum pobj_tx_lock lock_type() const noexcept
The type of lock needed for the transaction API.
Definition: mutex.hpp:161
void unlock()
Unlocks a previously locked mutex.
Definition: mutex.hpp:136