|
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TheTimedMutex requirements extend theTimedLockable requirements to include inter-thread synchronization.
Contents |
Additionally, for an objectm ofTimedMutex type:
duration. Ifduration is less or equalduration.zero(), attempts to obtain the ownership without blocking (as if bytry_lock()). Otherwise, this function blocks until the mutex is acquired or until the time specified byduration passes. It returns withinduration only if it succeeds, but it is allowed to fail to acquire the mutex even if at some point in time duringduration it was not owned by another thread. In any case, it returnstrue if the mutex was acquired andfalse otherwise.try_lock_for(duration) succeeds, priorunlock() operations on the same objectsynchronize-with this operation (equivalent to release-acquirestd::memory_order).time_point. Iftime_point already passed, attempts to obtain the ownership without blocking (as if bytry_lock()). Otherwise, this function blocks until the mutex is acquired or until the time specified bytime_point passes. It returns beforetime_point only if it succeeds, but it is allowed to fail to acquire the mutex even if at some point in time beforetime_point it was not owned by another thread. In any case, it returnstrue if the mutex was acquired andfalse otherwise.try_lock_until(time_point) succeeds, priorunlock() operations on the same objectsynchronize-with this operation (equivalent to release-acquirestd::memory_order).The following standard library types satisfyTimedMutex requirements:
(C++11) | provides mutual exclusion facility which can be locked recursively by the same thread and implements locking with a timeout (class)[edit] |
(C++14) | provides shared mutual exclusion facility and implements locking with a timeout (class)[edit] |
(C++11) | provides mutual exclusion facility which implements locking with a timeout (class)[edit] |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 2093 | C++11 | timeout-related exceptions were missing in the specification | mentioned |