monitor


An os_monitor is a template class that is derived from os_read_write_semaphore . When an os_monitor is constructed, it is associated with the object to be locked. Threads that wish to lock and access this object must adopt a cooperative scheme in which read_lock() is used to request a read lock, write_lock() is used to request a write lock, and operator* and operator-> are used to access the monitor's associated object. The functions read_unlock() and write_unlock() should be used to unlock the monitor when access to its associated object is no longer required.

Library

Thread<ToolKit>

Declaration

#include <ospace/thread/monitor.h>

template< class T >
class os_monitor : public os_read_write_semaphore

Interface

Constructor
os_monitor( T& object )
Constructs a monitor to guard access to object .

Throws: os_thread_toolkit_error

*
const T& operator*() const
Returns a reference to the object being monitored.
*
T& operator*()
Returns a reference to the object being monitored.
->
const T* operator->() const
Returns a pointer to the object being monitored.
->
T* operator->()
Returns a pointer to the object being monitored.

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