CppCommon
1.0.4.1
C++ Common Library
|
Named mutex synchronization primitive. More...
#include <named_mutex.h>
Public Member Functions | |
NamedMutex (const std::string &name) | |
Default class constructor. More... | |
NamedMutex (const NamedMutex &)=delete | |
NamedMutex (NamedMutex &&mutex)=delete | |
~NamedMutex () | |
NamedMutex & | operator= (const NamedMutex &)=delete |
NamedMutex & | operator= (NamedMutex &&mutex)=delete |
const std::string & | name () const |
Get the mutex name. More... | |
bool | TryLock () |
Try to acquire mutex without block. More... | |
bool | TryLockFor (const Timespan ×pan) |
Try to acquire mutex for the given timespan. More... | |
bool | TryLockUntil (const UtcTimestamp ×tamp) |
Try to acquire mutex until the given timestamp. More... | |
void | Lock () |
Acquire mutex with block. More... | |
void | Unlock () |
Release mutex. More... | |
Named mutex synchronization primitive.
Named mutex behaves as a simple mutex but could be shared between processes on the same machine.
Thread-safe.
Definition at line 29 of file named_mutex.h.
|
explicit |
Default class constructor.
name | - Mutex name |
Definition at line 176 of file named_mutex.cpp.
|
delete |
|
delete |
CppCommon::NamedMutex::~NamedMutex | ( | ) |
Definition at line 187 of file named_mutex.cpp.
void CppCommon::NamedMutex::Lock | ( | ) |
const std::string & CppCommon::NamedMutex::name | ( | ) | const |
Get the mutex name.
Definition at line 193 of file named_mutex.cpp.
|
delete |
|
delete |
bool CppCommon::NamedMutex::TryLock | ( | ) |
Try to acquire mutex without block.
Will not block.
Definition at line 195 of file named_mutex.cpp.
bool CppCommon::NamedMutex::TryLockFor | ( | const Timespan & | timespan | ) |
Try to acquire mutex for the given timespan.
Will block for the given timespan in the worst case.
timespan | - Timespan to wait for the mutex |
Definition at line 196 of file named_mutex.cpp.
|
inline |
Try to acquire mutex until the given timestamp.
Will block until the given timestamp in the worst case.
timestamp | - Timestamp to stop wait for the mutex |
Definition at line 70 of file named_mutex.h.
void CppCommon::NamedMutex::Unlock | ( | ) |
Release mutex.
Will not block.
Definition at line 199 of file named_mutex.cpp.