2.6 KiB
[thread.timedmutex.class]
32 Concurrency support library [thread]
32.6 Mutual exclusion [thread.mutex]
32.6.4 Mutex requirements [thread.mutex.requirements]
32.6.4.3 Timed mutex types [thread.timedmutex.requirements]
32.6.4.3.2 Class timed_mutex [thread.timedmutex.class]
namespace std {class timed_mutex {public: timed_mutex(); ~timed_mutex();
timed_mutex(const timed_mutex&) = delete; timed_mutex& operator=(const timed_mutex&) = delete; void lock(); // blockingbool try_lock(); template<class Rep, class Period>bool try_lock_for(const chrono::duration<Rep, Period>& rel_time); template<class Clock, class Duration>bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time); void unlock(); using native_handle_type = implementation-defined; // see [thread.req.native] native_handle_type native_handle(); // see [thread.req.native]};}
The class timed_mutex provides a non-recursive mutex with exclusive ownership semantics.
If one thread owns a timed_mutex object, attempts by another thread to acquire ownership of that object will fail (for try_lock()) or block (for lock(), try_lock_for(), and try_lock_until()) until the owning thread has released ownership with a call to unlock() or the call to try_lock_for() or try_lock_until() times out (having failed to obtain ownership).
The class timed_mutex meets all of the timed mutex requirements ([thread.timedmutex.requirements]).
It is a standard-layout class ([class.prop]).
The behavior of a program is undefined if
it destroys a timed_mutex object owned by any thread,
a thread that owns a timed_mutex object calls lock(),try_lock(), try_lock_for(), or try_lock_until() on that object, or
a thread terminates while owning a timed_mutex object.