ucommon
|
The Mutex Counter is a counter variable which can safely be incremented or decremented by multiple threads. More...
#include <thread.h>
Inherits ost::Mutex.
Public Member Functions | |
MutexCounter () | |
Create and optionally name a mutex protected counter. | |
MutexCounter (int initial) | |
Create and optionally name a mutex protected counter with an initial value. More... | |
int | operator++ () |
int | operator-- () |
![]() | |
void | enter (void) |
void | enterMutex (void) |
void | leave (void) |
void | leaveMutex (void) |
bool | test (void) |
bool | tryEnterMutex (void) |
Protected Attributes | |
volatile int | counter |
![]() | |
pthread_t | locker |
unsigned | lockers |
unsigned | waiting |
Additional Inherited Members | |
![]() | |
virtual void | _lock (void) |
virtual void | _unlock (void) |
void | lock (void) |
Acquire or increase locking. | |
bool | lock (timeout_t timeout) |
Timed lock request. | |
RecursiveMutex () | |
Create rexlock. | |
void | release (void) |
Release or decrease locking. | |
void | exclusive_lock (void) |
Access interface to exclusive lock the object. | |
void | release_exclusive (void) |
Access interface to release a lock. | |
The Mutex Counter is a counter variable which can safely be incremented or decremented by multiple threads.
A Mutex is used to protect access to the counter variable (an integer). An initial value can be specified for the counter, and it can be manipulated with the ++ and – operators.
ost::MutexCounter::MutexCounter | ( | int | initial | ) |
Create and optionally name a mutex protected counter with an initial value.
initial | value of counter. |