simple_priority_mutex


A simple, non-recursive mutex that guarantees order of obtainment using a fixed-priority scheduling mechanism. The thread with the highest priority acquires a lock on the mutex when it becomes available. Threads with equal priorities acquire locks on a first-in, first-out (FIFO) basis. Although multiple locks can be acquired by a thread, a single unlock operation completely releases the mutex.

Library

Thread<ToolKit>

Declaration

#include <ospace/thread/spriority.h>

class os_simple_priority_mutex

Interface

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

Throws: os_thread_toolkit_error

Destructor
~os_simple_priority_mutex()
Destroys the mutex.
lock
void lock( int priority )
Acquires a lock, blocking if necessary. If a lock is not immediately available, schedules the order of obtainment using priority (default 0 ). Multiple locks can be obtained by the same thread.

Throws: os_thread_toolkit_error

obtain
void obtain( int priority )
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 acquire a lock without blocking. Returns true if successful.

Throws: os_thread_toolkit_error

unlock
void unlock()
Releases all locks. A thread cannot make subsequent calls to unlock() without first obtaining a new lock on the mutex.

Throws: os_thread_toolkit_error


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