description | title | ms.date | f1_keywords | ms.assetid | helpviewer_keywords | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: recursive_mutex Class |
recursive_mutex Class |
11/04/2016 |
|
eb5ffd1b-7e78-4559-8391-bb220ead42fc |
|
Represents a mutex type. In contrast to mutex, the behavior of calls to locking methods for objects that are already locked is well-defined.
class recursive_mutex;
Name | Description |
---|---|
recursive_mutex | Constructs a recursive_mutex object. |
~recursive_mutex Destructor | Releases any resources that are used by the recursive_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. |
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 method returns immediately, and the previous lock remains in effect.
Constructs a recursive_mutex
object that is not locked.
recursive_mutex();
Releases any resources that are used by the object.
~recursive_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() noexcept;
true
if the method successfully obtains ownership of the mutex
or if the calling thread already owns the mutex**; otherwise, **false
.
If the calling thread already owns the mutex
, the function immediately returns true
, and the previous lock remains in effect.
Releases ownership of the mutex.
void unlock();
This method releases ownership of the mutex
only after it is called as many times as lock and try_lock have been called successfully on the recursive_mutex
object.
If the calling thread does not own the mutex
, the behavior is undefined.