std::defer_lock,std::try_to_lock,std::adopt_lock (3) - Linux Manuals
std::defer_lock,std::try_to_lock,std::adopt_lock: std::defer_lock,std::try_to_lock,std::adopt_lock
NAME
std::defer_lock,std::try_to_lock,std::adopt_lock - std::defer_lock,std::try_to_lock,std::adopt_lock
Synopsis
Defined in header <mutex>
constexpr std::defer_lock_t defer_lock {}; (since C++11)
inline constexpr std::defer_lock_t defer_lock {}; (since C++17)
constexpr std::try_to_lock_t try_to_lock {}; (since C++11)
inline constexpr std::try_to_lock_t try_to_lock {}; (since C++17)
constexpr std::adopt_lock_t adopt_lock {}; (since C++11)
inline constexpr std::adopt_lock_t adopt_lock {}; (since C++17)
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 strategies for std::lock_guard, 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