XII Release 0.1.0
Loading...
Searching...
No Matches
xiiMutex Class Reference

Copyright (c) Theophilus Eriata. All Rights Reserved. More...

#include <Mutex.h>

Inheritance diagram for xiiMutex:
[legend]

Public Member Functions

 xiiMutex ()
 Copyright (c) Theophilus Eriata. All Rights Reserved.
void Lock ()
 Acquires an exclusive lock for this mutex object.
xiiResult TryLock ()
void Unlock ()
 Releases a lock that has been previously acquired.
XII_ALWAYS_INLINE bool IsLocked () const
xiiMutexHandle & GetMutexHandle ()

Detailed Description

Copyright (c) Theophilus Eriata. All Rights Reserved.

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 xiiLock class or XII_LOCK macro.

See also
xiiSemaphore, xiiConditionVariable

Member Function Documentation

◆ IsLocked()

XII_ALWAYS_INLINE bool xiiMutex::IsLocked ( ) const
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.

◆ TryLock()

xiiResult xiiMutex::TryLock ( )
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.


The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Engine/Foundation/Threading/Mutex.h
  • /home/runner/work/XII/XII/Source/Engine/Foundation/Threading/Implementation/Posix/Mutex_posix.h
  • /home/runner/work/XII/XII/Source/Engine/Foundation/Threading/Implementation/Win/Mutex_win.h