libcommonc++
0.7
|
A critical section, a synchronization primitive that is typically more efficient than but roughly semantically equivalent to a Mutex. More...
#include <CriticalSection.h++>
Public Member Functions | |
CriticalSection () | |
Constructor. More... | |
~CriticalSection () | |
Destructor. More... | |
void | enter () |
Enter the critical section, blocking if necessary. More... | |
void | lock () |
Equivalent to enter(). More... | |
bool | tryEnter () |
Try to enter the critical section, returning immediately if it could not be entered. More... | |
void | leave () |
Leave the critical section. More... | |
void | unlock () |
Equivalent to leave(). More... | |
A critical section, a synchronization primitive that is typically more efficient than but roughly semantically equivalent to a Mutex.
Only one thread may be "within" a CriticalSection at any one time.
CriticalSections are recursive, so a thread may re-enter a CriticalSection that it has already entered. However, the thread must leave the CriticalSection the same number of times that it has entered it in order to release it.
See also ScopedLock.
CriticalSection | ( | ) |
Constructor.
~CriticalSection | ( | ) |
Destructor.
It is the calling code's responsibility to ensure that a CriticalSection is deleted only when no thread is within it.
void enter | ( | ) |
Enter the critical section, blocking if necessary.
void leave | ( | ) |
Leave the critical section.
bool tryEnter | ( | ) |
Try to enter the critical section, returning immediately if it could not be entered.