sem_lock


This template class allows a semaphore to be auto-locked within a scope. The lock must be instantiated on a synchronization object that understands lock() and unlock() . When an os_sem_lock is constructed with a reference to a semaphore, the os_sem_lock calls lock() on the associated semaphore. When an os_sem_lock is destroyed, it calls unlock() on the associated semaphore. An os_sem_lock is merely a helper class and does not own its semaphore.

Library

Thread<ToolKit>

Declaration

#include <ospace/thread/lock.h>

template< class Semaphore >
class os_sem_lock

Interface

Constructor
os_sem_lock( Semaphore& semaphore )
Constructs a barrier that immediately acquires a lock on semaphore , blocking if necessary.

Throws: any exception thrown by semaphore .lock() .

Destructor
~os_sem_lock()
Releases a lock on the associated semaphore.

Throws: any exception thrown by semaphore .unlock() .


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