相关文章推荐
精明的核桃  ·  dotnet add reference ...·  2 周前    · 
大气的剪刀  ·  Configure a debezium ...·  1 年前    · 
温文尔雅的豆腐  ·  [python opencv ...·  1 年前    · 

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge More info about Internet Explorer and Microsoft Edge

Represents a mutex type . Objects of this type can be used to enforce mutual exclusion within a program.

Syntax

class mutex;

Members

Public constructor/destructor

Description

Namespace: std

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

void lock();

Remarks

If the calling thread already owns the mutex, the behavior is undefined.

Constructor

Constructs a mutex object that isn't locked.
Microsoft's implementation of this constructor is not constexpr.

mutex() noexcept;

Destructor

Releases any resources that are used by the mutex object.

~mutex();

Remarks

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

native_handle

Returns the implementation-specific type that represents the mutex handle. The mutex handle can be used in implementation-specific ways.

native_handle_type native_handle();

Return Value

native_handle_type is defined as a Concurrency::critical_section * that's cast as void *.

try_lock

Attempts to obtain ownership of the mutex without blocking.

bool try_lock();

Return value

true if the method successfully obtains ownership of the mutex; otherwise, false.

Remarks

If the calling thread already owns the mutex, the behavior is undefined.

unlock

Releases ownership of the mutex.

void unlock();

Remarks

If the calling thread doesn't own the mutex, the behavior is undefined.

See also

Header Files Reference
<mutex>