Muokkaa

Jaa


Mutex Class

Represents a synchronization object that exclusively controls a shared resource.

Syntax

class Mutex : public HandleT<HandleTraits::MutexTraits>;

Members

Public Typedefs

Name Description
SyncLock A synonym for a class that supports synchronous locks.

Public Constructor

Name Description
Mutex::Mutex Initializes a new instance of the Mutex class.

Public Members

Name Description
Mutex::Lock Waits until the current object, or the Mutex object associated with the specified handle, releases the mutex or the specified time-out interval has elapsed.

Public Operator

Name Description
Mutex::operator= Assigns (moves) the specified Mutex object to the current Mutex object.

Inheritance Hierarchy

Mutex

Requirements

Header: corewrappers.h

Namespace: Microsoft::WRL::Wrappers

Mutex::Lock

Waits until the current object, or the Mutex object associated with the specified handle, releases the mutex or the specified time-out interval has elapsed.

SyncLock Lock(
   DWORD milliseconds = INFINITE
);

static SyncLock Lock(
   HANDLE h,
   DWORD milliseconds = INFINITE
);

Parameters

milliseconds
The time-out interval, in milliseconds. The default value is INFINITE, which waits indefinitely.

h
The handle of a Mutex object.

Return Value

Mutex::Mutex

Initializes a new instance of the Mutex class.

explicit Mutex(
   HANDLE h
);

Mutex(
   _Inout_ Mutex&& h
);

Parameters

h
A handle, or an rvalue-reference to a handle, to a Mutex object.

Remarks

The first constructor initializes a Mutex object from the specified handle. The second constructor initializes a Mutex object from the specified handle, and then moves ownership of the mutex to the current Mutex object.

Mutex::operator=

Assigns (moves) the specified Mutex object to the current Mutex object.

Mutex& operator=(
   _Inout_ Mutex&& h
);

Parameters

h
An rvalue-reference to a Mutex object.

Return Value

A reference to the current Mutex object.

Remarks

For more information, see the Move Semantics section of Rvalue Reference Declarator: &&.