condition_mutex


To ensure that a shared resource, specifically a condition variable, can only be accessed by one thread at a time, use a condition mutex semaphore. Depending upon the underlying platform, the lock attempt will fail or the thread will deadlock if it tries to obtain a mutex that it already owns.

Library

Thread<ToolKit>

Declaration

#include <ospace/thread/cmutex.h>

class os_condition_mutex

Interface

Constructor
os_condition_mutex( bool locked )
Constructs a condition mutex with an initial locked (default false ) state.

Throws: os_thread_toolkit_error

Destructor
~os_condition_mutex()
Destroys this mutex.
lock
void lock()
Acquires the lock, blocking if necessary. Depending upon the underlying platform, the lock attempt will fail or the thread will deadlock if it tries to obtain a mutex that it already owns.

Throws: os_thread_toolkit_error

obtain
void obtain()
Synonym for lock() ; alternative acquisition syntax.

Throws: os_thread_toolkit_error

release
void release()
Synonym for unlock() ; alternative acquisition syntax.

Throws: os_thread_toolkit_error

try_lock
bool try_lock()
Attempts to lock this mutex, with no blocking. Returns true if successful.

Throws: os_thread_toolkit_error

unlock
void unlock()
Releases the lock.

Throws: os_thread_toolkit_error


Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.