The Mutex requirements extends the Lockable requirements to include inter-thread synchronization.
For an object m
of Mutex type:
m.lock()
has the following properties m.unlock()
operations on the same mutex synchronize-with this lock operation (equivalent to release-acquire std::memory_order
) std::recursive_mutex
or std::recursive_timed_mutex
) std::system_error
may be thrown on errors, with the following error codes: std::errc::operation_not_permitted
if the calling thread does not have required privileges std::errc::resource_deadlock_would_occur
if the implementation detects that this operation would lead to deadlock m.try_lock()
has the following properties try_lock()
succeeds, prior unlock()
operations on the same object synchronize-with this operation (equivalent to release-acquire std::memory_order
). lock()
does not synchronize with a failed try_lock()
m.unlock()
has the following properties The following standard library types satisfy Mutex:
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 2309 | C++11 | lock might throw std::system_error with error code std::errc::device_or_resource_busy | not allowed |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/named_req/Mutex