This class implements a mutex. More...
#include <CMutex.h>
Public Member Functions | |
cMutex () | |
Constructor of cMutex. More... | |
virtual | ~cMutex () |
Destructor of cMutex. More... | |
bool | acquire () |
This method acquires the mutex. More... | |
bool | tryAcquire () |
This method acquires the mutex only if it is not owned by another thread. More... | |
void | release () |
This method releases the mutex. More... | |
Protected Attributes | |
CRITICAL_SECTION | m_mutex |
Mutex handle. More... | |
A mutex object is a synchronization object whose state is set to signaled when it is not owned by any thread, and non-signaled when it is owned. Only one thread at a time can own a mutex object, whose name comes from the fact that it is useful in coordinating mutually exclusive access to a shared resource. For example, to prevent two threads from writing to shared memory at the same time, each thread waits for ownership of a mutex object before executing the code that accesses the memory. After writing to the shared memory, the thread releases the mutex object.
chai3d::cMutex::cMutex | ( | ) |
Constructor of cMutex.
|
virtual |
Destructor of cMutex.
bool chai3d::cMutex::acquire | ( | ) |
This method requests ownership of the mutex. The calling thread will wait until the mutex becomes available, or until a system timeout occurs (in which case the call is not successful).
bool chai3d::cMutex::tryAcquire | ( | ) |
This method requests ownership of the mutex. The calling thread will return false immediately if the mutex is already owned by another thread. Otherwise, the calling thread is granted ownership of the mutex.
void chai3d::cMutex::release | ( | ) |
This method makes the calling thread release ownership of the mutex.
|
protected |