PMDK C++ bindings
1.11
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Persistent memory resident timed_mutex implementation. More...
#include <libpmemobj++/timed_mutex.hpp>
Public Types | |
typedef PMEMmutex * | native_handle_type |
Implementation defined handle to the native type. | |
Public Member Functions | |
timed_mutex () | |
Default constructor. More... | |
~timed_mutex ()=default | |
Defaulted destructor. | |
void | lock () |
Locks the mutex, blocks if already locked. More... | |
bool | try_lock () |
Tries to lock the mutex, returns regardless if the lock succeeds. More... | |
template<typename Clock , typename Duration > | |
bool | try_lock_until (const std::chrono::time_point< Clock, Duration > &timeout_time) |
Makes the current thread block until the lock is acquired or a specific time is reached. More... | |
template<typename Rep , typename Period > | |
bool | try_lock_for (const std::chrono::duration< Rep, Period > &timeout_duration) |
Makes the current thread block until the lock is acquired or a specified amount of time passes. More... | |
void | unlock () |
Unlocks a previously locked mutex. More... | |
native_handle_type | native_handle () noexcept |
Access a native handle to this condition variable. More... | |
timed_mutex & | operator= (const timed_mutex &)=delete |
Deleted assignment operator. | |
timed_mutex (const timed_mutex &)=delete | |
Deleted copy constructor. | |
Private Member Functions | |
template<typename Clock , typename Duration > | |
bool | timedlock_impl (const std::chrono::time_point< Clock, Duration > &abs_time) |
Internal implementation of the timed lock call. | |
Private Attributes | |
PMEMmutex | plock |
A POSIX style PMEM-resident timed_mutex. | |
Persistent memory resident timed_mutex implementation.
This class is an implementation of a PMEM-resident timed_mutex which mimics in behavior the C++11 std::timed_mutex. This class satisfies all requirements of the TimedMutex and StandardLayoutType concepts. The typical usage example would be:
|
inline |
Default constructor.
lock_error | when the timed_mutex is not from persistent memory. |
|
inline |
Locks the mutex, blocks if already locked.
If a different thread already locked this mutex, the calling thread will block. If the same thread tries to lock a mutex it already owns, the behavior is undefined.
lock_error | when an error occurs, this includes all system related errors with the underlying implementation of the mutex. |
|
inlinenoexcept |
Access a native handle to this condition variable.
|
inline |
Tries to lock the mutex, returns regardless if the lock succeeds.
If the same thread tries to lock a mutex it already owns, the behavior is undefined.
true
on successful lock acquisition, false
otherwise.lock_error | when an error occurs, this includes all system related errors with the underlying implementation of the mutex. |
|
inline |
Makes the current thread block until the lock is acquired or a specified amount of time passes.
If the same thread tries to lock a mutex it already owns, the behavior is undefined.
[in] | timeout_duration | a specific duration, which when expired unblocks the thread. |
true
on successful lock acquisition, false
otherwise.lock_error | when an error occurs, this includes all system related errors with the underlying implementation of the mutex. |
|
inline |
Makes the current thread block until the lock is acquired or a specific time is reached.
If the same thread tries to lock a mutex it already owns, the behavior is undefined.
[in] | timeout_time | a specific point in time, which when reached unblocks the thread. |
true
on successful lock acquisition, false
otherwise.lock_error | when an error occurs, this includes all system related errors with the underlying implementation of the mutex. |
|
inline |
Unlocks a previously locked mutex.
Unlocking a mutex that has not been locked by the current thread results in undefined behavior. Unlocking a mutex that has not been lock also results in undefined behavior.