![]() |
Plasma Engine
2.0
|
Provides a simple mechanism for mutual exclusion to prevent multiple threads from accessing a shared resource simultaneously. More...
#include <Mutex.h>
Public Member Functions | |
void | Lock () |
Acquires an exclusive lock for this mutex object. | |
plResult | TryLock () |
Attempts to acquire an exclusive lock for this mutex object. Returns true on success. | |
void | Unlock () |
Releases a lock that has been previously acquired. | |
PL_ALWAYS_INLINE bool | IsLocked () const |
Returns true, if the mutex is currently acquired. Can be used to assert that a lock was entered. | |
plMutexHandle & | GetMutexHandle () |
Provides a simple mechanism for mutual exclusion to prevent multiple threads from accessing a shared resource simultaneously.
This can be used to protect code that is not thread-safe against race conditions. To ensure that mutexes are always properly released, use the plLock class or PL_LOCK macro.
|
inline |
Returns true, if the mutex is currently acquired. Can be used to assert that a lock was entered.
Obviously, this check is not thread-safe and should not be used to check whether a mutex could be locked without blocking. Use TryLock for that instead.
|
inline |
Attempts to acquire an exclusive lock for this mutex object. Returns true on success.
If the mutex is already acquired by another thread, the function returns immediately and returns false.