![]() |
ezEngine
Release 25.03
|
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. | |
ezResult | TryLock () |
Attempts to acquire an exclusive lock for this mutex object. Returns true on success. More... | |
void | Unlock () |
Releases a lock that has been previously acquired. | |
EZ_ALWAYS_INLINE bool | IsLocked () const |
Returns true, if the mutex is currently acquired. Can be used to assert that a lock was entered. More... | |
ezMutexHandle & | 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 ezLock class or EZ_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.