description | title | ms.date | f1_keywords | ms.assetid | helpviewer_keywords | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: timed_mutex Class |
timed_mutex Class |
11/04/2016 |
|
cd198081-6f38-447a-9dba-e06dfbfafe59 |
|
Represents a timed mutex type. Objects of this type are used to enforce mutual exclusion through time-limited blocking within a program.
class timed_mutex;
Name | Description |
---|---|
timed_mutex | Constructs a timed_mutex object that's not locked. |
timed_mutex::~timed_mutex Destructor | Releases any resources that are used by the timed_mutex object. |
Name | Description |
---|---|
lock | Blocks the calling thread until the thread obtains ownership of the mutex . |
try_lock | Attempts to obtain ownership of the mutex without blocking. |
try_lock_for | Attempts to obtain ownership of the mutex for a specified time interval. |
try_lock_until | Attempts to obtain ownership of the mutex until a specified time. |
unlock | Releases ownership of the mutex . |
Header: <mutex>
Namespace: std
Blocks the calling thread until the thread obtains ownership of the mutex
.
void lock();
If the calling thread already owns the mutex
, the behavior is undefined.
Constructs a timed_mutex
object that is not locked.
timed_mutex();
Releases any resources that are used by the mutex
object.
~timed_mutex();
If the object is locked when the destructor runs, the behavior is undefined.
Attempts to obtain ownership of the mutex
without blocking.
bool try_lock();
true
if the method successfully obtains ownership of the mutex
; otherwise, false
.
If the calling thread already owns the mutex
, the behavior is undefined.
Attempts to obtain ownership of the mutex
without blocking.
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& Rel_time);
Rel_time
A chrono::duration object that specifies the maximum amount of time that the method attempts to obtain ownership of the mutex
.
true
if the method successfully obtains ownership of the mutex
; otherwise, false
.
If the calling thread already owns the mutex
, the behavior is undefined.
Attempts to obtain ownership of the mutex
without blocking.
template <class Clock, class Duration>
bool try_lock_for(const chrono::time_point<Clock, Duration>& Abs_time);
bool try_lock_until(const xtime* Abs_time);
Abs_time
A point in time that specifies the threshold after which the method no longer attempts to obtain ownership of the mutex
.
true
if the method successfully obtains ownership of the mutex
; otherwise, false
.
If the calling thread already owns the mutex
, the behavior is undefined.
Releases ownership of the mutex
.
void unlock();
If the calling thread does not own the mutex
, the behavior is undefined.