C4 Engine
C4 Engine API Documentation

class Mutex

Defined in:  C4Root.h
The Mutex class encapsulates a mutual exclusion object for multithreaded synchronization.
Definition

class Mutex

Member Functions
Mutex::Acquire Acquires exclusive ownership of a mutex.
Mutex::TryAcquire Attempts to acquire exclusive ownership of a mutex.
Mutex::Release Releases ownership of a mutex.
Constructor

Mutex();

Description
The Mutex class defines a platform-independent mutual exclusion object that can be used for multithreaded synchronization. A mutex can only be owned by one thread at a time and when properly used prevents simultaneous access to resources by multiple threads.

Ownership of a mutex is acquired by calling the Mutex::Acquire function. If the mutex is already owned by a different thread when this function is called, then the calling thread blocks until the mutex becomes available. The Mutex::TryAcquire function attempts to acquire ownership of a mutex, but does not block if acquisition fails. Ownership of a mutex is relinquished by calling the Mutex::Release function.
WARNING. If a mutex object is destroyed while a thread is waiting to acquire it, then the behavior is undefined.
See Also

Lock

Signal

Thread