Mutex. More...
#include <rmutex.h>
Public Member Functions | |
RMutex (void) | |
void | Lock (void) |
void | UnLock (void) |
void | TryLock (void) |
pthread_mutex_t * | GetMutex (void) |
virtual | ~RMutex (void) |
Private Attributes | |
pthread_mutex_t | Mutex |
Detailed Description
Mutex.
The RMutex class provides a representation for a mutex used for thread synchronization.
Lets suppose that two functions, func1 and func2, used by two different threads access the same variable (an account for example). A mutex can be used to ensure that, at one moment, only one thread can access the variable.
Constructor & Destructor Documentation
RMutex | ( | void | ) |
Construct the mutex.
|
virtual |
Destruct the mutex. The behaviour of the program is unkwown if the mutex is still locked.
Member Function Documentation
void Lock | ( | void | ) |
Lock the mutex. If the mutex is already locked, the calling thread is blocked.
void UnLock | ( | void | ) |
Unlock the mutex. If threads are blocked because of this mutex, one of them (depending of the priority schema) is wake up.
void TryLock | ( | void | ) |
Try to lock the mutex. If the mutex is already locked, the method returns also. This method must be used carefully.
pthread_mutex_t* GetMutex | ( | void | ) |
Get the pthread pointer of the mutex.
Field Documentation
|
private |
Pointer to a mutex structure.