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.")
104 .with_pmemobj_errormsg();
124 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
125 int ret = pmemobj_mutex_trylock(pop, &this->
plock);
129 else if (ret == EBUSY)
133 "Failed to lock a mutex.")
134 .with_pmemobj_errormsg();
147 PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
148 int ret = pmemobj_mutex_unlock(pop, &this->
plock);
151 "Failed to unlock a mutex.")
152 .with_pmemobj_errormsg();
174 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:172
~mutex()=default
Defaulted destructor.
native_handle_type native_handle() noexcept
Access a native handle to this condition variable.
Definition: mutex.hpp:161
PMEMmutex plock
A POSIX style PMEM-resident mutex.
Definition: mutex.hpp:189
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:109
bool try_lock()
Tries to lock the mutex, returns regardless if the lock succeeds.
Definition: mutex.hpp:122
void unlock()
Unlocks a previously locked mutex.
Definition: mutex.hpp:145
A persistent version of concurrent hash map implementation Ref: https://arxiv.org/abs/1509....
Definition: allocation_flag.hpp:43