Skip to content

Latest commit

 

History

History
107 lines (68 loc) · 3.04 KB

recursive-mutex-class.md

File metadata and controls

107 lines (68 loc) · 3.04 KB
description title ms.date f1_keywords ms.assetid helpviewer_keywords
Learn more about: recursive_mutex Class
recursive_mutex Class
11/04/2016
mutex/std::recursive_mutex
mutex/std::recursive_mutex::recursive_mutex
mutex/std::recursive_mutex::lock
mutex/std::recursive_mutex::try_lock
mutex/std::recursive_mutex::unlock
eb5ffd1b-7e78-4559-8391-bb220ead42fc
std::recursive_mutex [C++]
std::recursive_mutex [C++], recursive_mutex
std::recursive_mutex [C++], lock
std::recursive_mutex [C++], try_lock
std::recursive_mutex [C++], unlock

recursive_mutex Class

Represents a mutex type. In contrast to mutex, the behavior of calls to locking methods for objects that are already locked is well-defined.

Syntax

class recursive_mutex;

Members

Public Constructors

Name Description
recursive_mutex Constructs a recursive_mutex object.
~recursive_mutex Destructor Releases any resources that are used by the recursive_mutex object.

Public Methods

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.

Requirements

Header: <mutex>

Namespace: std

lock

Blocks the calling thread until the thread obtains ownership of the mutex.

void lock();

Remarks

If the calling thread already owns the mutex, the method returns immediately, and the previous lock remains in effect.

recursive_mutex

Constructs a recursive_mutex object that is not locked.

recursive_mutex();

~recursive_mutex

Releases any resources that are used by the object.

~recursive_mutex();

Remarks

If the object is locked when the destructor runs, the behavior is undefined.

try_lock

Attempts to obtain ownership of the mutex without blocking.

bool try_lock() noexcept;

Return Value

true if the method successfully obtains ownership of the mutex or if the calling thread already owns the mutex**; otherwise, **false.

Remarks

If the calling thread already owns the mutex, the function immediately returns true, and the previous lock remains in effect.

unlock

Releases ownership of the mutex.

void unlock();

Remarks

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.

See also

Header Files Reference
<mutex>