38 #ifndef PMEMOBJ_MUTEX_HPP 39 #define PMEMOBJ_MUTEX_HPP 42 #include "libpmemobj/thread.h" 43 #include "libpmemobj/tx_base.h" 73 if ((pop = pmemobj_pool_by_ptr(&
plock)) ==
nullptr)
75 "Persistent mutex not from persistent" 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 (void)pmemobj_mutex_unlock(pop, &this->
plock);
168 return TX_PARAM_MUTEX;
PMEMmutex * native_handle_type
Implementation defined handle to the native type.
Definition: mutex.hpp:63
mutex()
Default constructor.
Definition: mutex.hpp:70
enum pobj_tx_param lock_type() const noexcept
The type of lock needed for the transaction API.
Definition: mutex.hpp:166
~mutex()=default
Defaulted destructor.
native_handle_type native_handle() noexcept
Access a native handle to this condition variable.
Definition: mutex.hpp:155
PMEMmutex plock
A POSIX style PMEM-resident mutex.
Definition: mutex.hpp:183
Persistent memory resident mutex implementation.
Definition: mutex.hpp:60
void lock()
Locks the mutex, blocks if already locked.
Definition: mutex.hpp:98
mutex & operator=(const mutex &)=delete
Deleted assignment operator.
Custom lock error class.
Definition: pexceptions.hpp:74
bool try_lock()
Tries to lock the mutex, returns regardless if the lock succeeds.
Definition: mutex.hpp:121
void unlock()
Unlocks a previously locked mutex.
Definition: mutex.hpp:143
Definition: allocator.hpp:48