Defines a mutually exclusive lock that can be used to coordinate with other threads.
Max size of the SbMutex type.
Enumeration of possible results from acquiring a mutex.
kSbMutexAcquired
The mutex was acquired successfully.
kSbMutexBusy
The mutex was not acquired because it was held by someone else.
kSbMutexDestroyed
The mutex has already been destroyed.
An opaque handle to a mutex type with reserved memory buffer of size SB_MUTEX_MAX_SIZE and aligned at void pointer type.
typedef union SbMutex SbMutex
Acquires mutex
, blocking indefinitely. The return value identifies the acquisition result. SbMutexes are not reentrant, so a recursive acquisition blocks forever.
mutex
: The mutex to be acquired.
SbMutexResult SbMutexAcquire(SbMutex *mutex)
Acquires mutex
, without blocking. The return value identifies the acquisition result. SbMutexes are not reentrant, so a recursive acquisition has undefined behavior.
mutex
: The mutex to be acquired.
SbMutexResult SbMutexAcquireTry(SbMutex *mutex)
Creates a new mutex. The return value indicates whether the function was able to create a new mutex.
out_mutex
: The handle to the newly created mutex.
bool SbMutexCreate(SbMutex *out_mutex)
Destroys a mutex. The return value indicates whether the destruction was successful. Destroying a locked mutex results in undefined behavior.
mutex
: The mutex to be invalidated.
bool SbMutexDestroy(SbMutex *mutex)
Indicates whether the given result is a success. A value of true
indicates that the mutex was acquired.
result
: The result being checked.
static bool SbMutexIsSuccess(SbMutexResult result)
Releases mutex
held by the current thread. The return value indicates whether the release was successful. Releases should always be successful if mutex
is held by the current thread.
mutex
: The mutex to be released.
bool SbMutexRelease(SbMutex *mutex)