std::defer_lock, std::try_to_lock, std::adopt_lock

From Cppreference

Jump to: navigation, search
constexpr defer_lock_t defer_lock = std::defer_lock_t();
(since C++11)
constexpr try_to_lock_t try_to_lock = std::try_to_lock_t();
(since C++11)
constexpr adopt_lock_t adopt_lock = std::adopt_lock_t();
(since C++11)

std::defer_lock, std::try_to_lock and std::adopt_lock are instances of empty struct tag types std::defer_lock_t, std::try_to_lock_t and std::adopt_lock_t respectively. They are used to specify locking strategy.

Type Effect(s)
defer_lock_t do not acquire ownership of the mutex
try_to_t try to acquire ownership of the mutex without blocking
adopt_lock_t assume the calling thread already has ownership of the mutex

[edit] Example

[edit] See also

tag type used to specify locking strategy
(class)