PMDK C++ bindings
1.8.1
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Persistent memory resident shared_mutex implementation. More...
#include <libpmemobj++/shared_mutex.hpp>
Public Types | |
typedef PMEMrwlock * | native_handle_type |
Implementation defined handle to the native type. | |
Public Member Functions | |
shared_mutex () | |
Default constructor. More... | |
~shared_mutex ()=default | |
Defaulted destructor. | |
void | lock () |
Lock the mutex for exclusive access. More... | |
void | lock_shared () |
Lock the mutex for shared access. More... | |
bool | try_lock () |
Try to lock the mutex for exclusive access, returns regardless if the lock succeeds. More... | |
bool | try_lock_shared () |
Try to lock the mutex for shared access, returns regardless if the lock succeeds. More... | |
void | unlock () |
Unlocks the mutex. More... | |
void | unlock_shared () |
Unlocks the mutex. More... | |
native_handle_type | native_handle () noexcept |
Access a native handle to this shared mutex. More... | |
enum pobj_tx_param | lock_type () const noexcept |
The type of lock needed for the transaction API. More... | |
shared_mutex & | operator= (const shared_mutex &)=delete |
Deleted assignment operator. | |
shared_mutex (const shared_mutex &)=delete | |
Deleted copy constructor. | |
Private Attributes | |
PMEMrwlock | plock |
A POSIX style PMEM-resident shared_mutex. | |
Persistent memory resident shared_mutex implementation.
This class is an implementation of a PMEM-resident share_mutex which mimics in behavior the C++11 std::mutex. This class satisfies all requirements of the SharedMutex and StandardLayoutType concepts. The typical usage would be:
|
inline |
Default constructor.
lock_error | when the shared_mutex is not from persistent memory. |
|
inline |
Lock the mutex for exclusive access.
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, either in exclusive or shared mode, the behavior is undefined.
lock_error | when an error occurs, this includes all system related errors with the underlying implementation of the mutex. |
|
inline |
Lock the mutex for shared access.
If a different thread already locked this mutex for exclusive access, the calling thread will block. If it was locked for shared access by a different thread, the lock will succeed.
The mutex can be locked for shared access multiple times by the same thread. If so, the same number of unlocks must be made to unlock the mutex.
lock_error | when an error occurs, this includes all system related errors with the underlying implementation of the mutex. |
|
inlinenoexcept |
The type of lock needed for the transaction API.
|
inlinenoexcept |
Access a native handle to this shared mutex.
|
inline |
Try to lock the mutex for exclusive access, returns regardless if the lock succeeds.
If the same thread tries to lock a mutex it already owns either in exclusive or shared mode, 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 |
Try to lock the mutex for shared access, returns regardless if the lock succeeds.
The mutex can be locked for shared access multiple times by the same thread. If so, the same number of unlocks must be made to unlock the mutex. If the calling thread already owns the mutex in any mode, the behavior is undefined.
false
if a different thread already locked the mutex for exclusive access, true
otherwise.lock_error | when an error occurs, this includes all system related errors with the underlying implementation of the mutex. |
|
inline |
Unlocks the mutex.
The mutex must be locked for exclusive access by the calling thread, otherwise results in undefined behavior.
|
inline |
Unlocks the mutex.
The mutex must be locked for shared access by the calling thread, otherwise results in undefined behavior.