The Mutex Counter is a counter variable which can safely be incremented or decremented by multiple threads.
More...
#include <thread.h>
|
| MutexCounter (const char *id=NULL) |
| Create and optionally name a mutex protected counter. More...
|
|
| MutexCounter (int initial, const char *id=NULL) |
| Create and optionally name a mutex protected counter with an initial value. More...
|
|
void | nameMutex (const char *name) |
| Enable setting of mutex name for deadlock debug. More...
|
|
void | enterMutex (void) |
| Entering a Mutex locks the mutex for the current thread. More...
|
|
void | enter (void) |
| Future abi will use enter/leave/test members. More...
|
|
void | leave (void) |
| Future abi will use enter/leave/test members. More...
|
|
bool | test (void) |
| Future abi will use enter/leave/test members. More...
|
|
bool | tryEnterMutex (void) |
| Tries to lock the mutex for the current thread. More...
|
|
void | leaveMutex (void) |
| Leaving a mutex frees that mutex for use by another thread. More...
|
|
|
static void | setDebug (bool mode) |
| Enable or disable deadlock debugging. More...
|
|
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.
- Author
- David Sugar dyfet.nosp@m.@ost.nosp@m.el.co.nosp@m.m Thread protected integer counter.
Definition at line 499 of file thread.h.
MutexCounter::MutexCounter |
( |
const char * |
id = NULL | ) |
|
Create and optionally name a mutex protected counter.
- Parameters
-
id | name for mutex counter, optional for deadlock testing. |
MutexCounter::MutexCounter |
( |
int |
initial, |
|
|
const char * |
id = NULL |
|
) |
| |
Create and optionally name a mutex protected counter with an initial value.
- Parameters
-
initial | value of counter. |
id | name of counter, optional for deadlock testing. |
void Mutex::enter |
( |
void |
| ) |
|
|
inlineinherited |
Future abi will use enter/leave/test members.
Definition at line 263 of file thread.h.
void Mutex::enterMutex |
( |
void |
| ) |
|
|
inherited |
Entering a Mutex locks the mutex for the current thread.
This also can be done using the ENTER_CRITICAL macro or by using the ++ operator on a mutex.
- See Also
- leaveMutex
void Mutex::leave |
( |
void |
| ) |
|
|
inlineinherited |
Future abi will use enter/leave/test members.
Definition at line 269 of file thread.h.
void Mutex::leaveMutex |
( |
void |
| ) |
|
|
inherited |
Leaving a mutex frees that mutex for use by another thread.
If the mutex has been entered (invoked) multiple times (recursivily) by the same thread, then it will need to be exited the same number of instances before it is free for re-use. This operation can also be done using the LEAVE_CRITICAL macro or by the – operator on a mutex.
- See Also
- enterMutex
void Mutex::nameMutex |
( |
const char * |
name | ) |
|
|
inlineinherited |
Enable setting of mutex name for deadlock debug.
- Parameters
-
Definition at line 248 of file thread.h.
static void Mutex::setDebug |
( |
bool |
mode | ) |
|
|
inlinestaticinherited |
Enable or disable deadlock debugging.
- Parameters
-
Definition at line 240 of file thread.h.
bool Mutex::test |
( |
void |
| ) |
|
|
inlineinherited |
Future abi will use enter/leave/test members.
- Returns
- true if entered.
Definition at line 277 of file thread.h.
bool Mutex::tryEnterMutex |
( |
void |
| ) |
|
|
inherited |
Tries to lock the mutex for the current thread.
Behaves like enterMutex , except that it doesn't block the calling thread if the mutex is already locked by another thread.
- Returns
- true if locking the mutex was succesful otherwise false
- See Also
- enterMutex
-
leaveMutex
volatile int MutexCounter::counter |
|
private |
The documentation for this class was generated from the following file: