std::defer_lock_t,std::try_to_lock_t,std::adopt_lock_t (3) - Linux Manuals
std::defer_lock_t,std::try_to_lock_t,std::adopt_lock_t: std::defer_lock_t,std::try_to_lock_t,std::adopt_lock_t
NAME
std::defer_lock_t,std::try_to_lock_t,std::adopt_lock_t - std::defer_lock_t,std::try_to_lock_t,std::adopt_lock_t
Synopsis
Defined in header <mutex>
struct defer_lock_t { }; (since C++11)
struct try_to_lock_t { }; (until C++17)
struct adopt_lock_t { };
struct defer_lock_t { explicit defer_lock_t() = default; };
struct try_to_lock_t { explicit try_to_lock_t() = default; }; (since C++17)
struct adopt_lock_t { explicit adopt_lock_t() = default; };
std::defer_lock_t, std::try_to_lock_t and std::adopt_lock_t are empty struct tag types used to specify locking strategy for std::lock_guard, std::scoped_lock, std::unique_lock, and std::shared_lock.
Type Effect(s)
defer_lock_t do not acquire ownership of the mutex
try_to_lock_t try to acquire ownership of the mutex without blocking
adopt_lock_t assume the calling thread already has ownership of the mutex
Example
// Run this code
See also
defer_lock
try_to_lock
adopt_lock tag constants used to specify locking strategy
(C++11)
(C++11)
(C++11)
constructor (public member function of std::lock_guard<Mutex>)
constructor (public member function of std::unique_lock<Mutex>)