[thread.timedmutex.class] (original) (raw)
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(); bool 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; native_handle_type native_handle(); };}
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 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.