#include <Mutex.h>
This kind of mutex can be used to synchronize multiple threads of the same process. No multiple processes!
CRITICAL_SECTION
(W32) wrapper.
Public Member Functions | |
Mutex () | |
Creates a new mutex. | |
~Mutex () | |
Destroys the mutex. | |
void | lock () |
Locks the mutex to enter in a critical section. | |
bool | tryLock () |
Tries to lock the mutex and returns true if it was locked. | |
void | unlock () |
Unlocks the mutex so another thread can lock it. | |
Private Attributes | |
CRITICAL_SECTION | m_cs |
Mutex::Mutex | ( | ) |
Mutex::~Mutex | ( | ) |
void Mutex::lock | ( | ) |
Locks the mutex to enter in a critical section.
Locks the mutex if it is free (not locked by another thread) or waits the mutex to be unlocked.
EnterCriticalSection
(W32). bool Mutex::tryLock | ( | ) |
void Mutex::unlock | ( | ) |
Unlocks the mutex so another thread can lock it.
You have to unlock a mutex to give access to another thread to enter in the critical section and use the shared resources that this mutex is guarding.
LeaveCriticalSection
(W32).
CRITICAL_SECTION Vaca::Mutex::m_cs [private] |