Include the standard header <mutex> to define the classes
recursive_timed_mutex; the templates
unique_lock; and supporting types and functions that define mutual-exclusion code regions.
Beginning in Visual Studio 2015, the C++ Standard Library synchronization types are based on Windows synchronization primitives and no longer use ConcRT (except when the target platform is Windows XP). The types defined in <mutex> should not be used with any ConcRT types or functions.
In code that is compiled by using /clr, this header is blocked.
recursive_mutex are mutex types. A mutex type has a default constructor and a destructor that does not throw exceptions. These objects have methods that provide mutual exclusion when multiple threads try to lock the same object. Specifically, a mutex type contains the methods
lockmethod blocks the calling thread until the thread obtains ownership of the mutex. Its return value is ignored.
try_lockmethod tries to obtain ownership of the mutex without blocking. Its return type is convertible to bool and is true if the method obtains ownership, but is otherwise false.
unlockmethod releases the ownership of the mutex from the calling thread.
You can use mutex types as type arguments to instantiate the templates
unique_lock. You can use objects of these types as the
Lock argument to the wait member functions in the template condition_variable_any.
A timed mutex type satisfies the requirements for a mutex type. In addition, it has the
try_lock_until methods that must be callable by using one argument and must return a type that is convertible to bool. A timed mutex type can define these functions by using additional arguments, provided that those additional arguments all have default values.
try_lock_formethod must be callable by using one argument,
Rel_time, whose type is an instantiation of chrono::duration. The method tries to obtain ownership of the mutex, but returns within the time that is designated by
Rel_time, regardless of success. The return value converts to true if the method obtains ownership; otherwise, the return value converts to false.
try_lock_untilmethod must be callable by using one argument,
Abs_time, whose type is an instantiation of chrono::time_point. The method tries to obtain ownership of the mutex, but returns no later than the time that is designated by
Abs_time, regardless of success. The return value converts to true if the method obtains ownership; otherwise, the return value converts to false.
A mutex type is also known as a lockable type. If it does not provide the member function
try_lock, it is a basic lockable type. A timed mutex type is also known as a timed lockable type.
|lock_guard Class||Represents a template that can be instantiated to create an object whose destructor unlocks a
|mutex Class (C++ Standard Library)||Represents a mutex type. Use objects of this type to enforce mutual exclusion within a program.|
|recursive_mutex Class||Represents a mutex type. In constrast to the
|recursive_timed_mutex Class||Represents a timed mutex type. Use objects of this type to enforce mutual exclusion that has time-limited blocking within a program. Unlike objects of type
|timed_mutex Class||Represents a timed mutex type. Use objects of this type to enforce mutual exclusion that has time-limited blocking within a program.|
|unique_lock Class||Represents a template that can be instantiated to create objects that manage the locking and unlocking of a
|call_once||Provides a mechanism for calling a specified callable object exactly once during execution.|
|lock||Attempts to lock all arguments without deadlock.|
|adopt_lock_t Structure||Represents a type that is used to define an
|defer_lock_t Structure||Represents a type that defines a
|once_flag Structure||Represents a struct that is used with the template function
|try_to_lock_t Structure||Represents a struct that defines a
|adopt_lock||Represents an object that can be passed to constructors for
|defer_lock||Represents an object that can be passed to the constructor for
|try_to_lock||Represents an object that can be passed to the constructor for