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