Namespaces
Variants
Views
Actions

C++ named requirements: SharedLockable

From cppreference.com
< cpp‎ | named req
Revision as of 02:20, 18 October 2021 by Fruderica (Talk | contribs)

 
 
C++ named requirements
 

The SharedLockable requirements describe the minimal characteristics of types that provide shared blocking semantics for execution agents (i.e. threads).

Requirements

For type L to be SharedLockable, the following conditions have to be satisfied for an object m of type L:

Expression Preconditions Effects Return value
m.lock_shared() Blocks until a lock can be obtained for the current execution agent (thread, process, task). If an exception is thrown, no lock is obtained.
m.try_lock_shared() Attempts to obtained a lock for the current execution agent (thread, process, task) without blocking. If an exception is thrown, no lock is obtained. true if the lock was obtained, false otherwise
m.unlock_shared() The current execution agent holds a shared lock on m. Releases the shared lock held by the execution agent.

Throws no exceptions.

Notes

The lock_shared and try_lock_shared member functions obtain a shared lock on m on succcess.

See also