deferlock
Defer_lock (often written with an underscore as defer_lock) refers to a tag type in the C++ standard library that indicates a mutex should not be locked when a lock object is constructed. It is exposed as the constant std::defer_lock of type defer_lock_t and is used to control when locking actually occurs.
The primary purpose of defer_lock is to give the programmer manual control over the locking operation. It
Example usage: std::mutex m; std::unique_lock<std::mutex> ul(m, std::defer_lock); // not locked yet ul.lock(); // lock when ready
In addition to defer_lock, there are related tagging options for std::unique_lock: std::try_to_lock attempts to lock during
Overview and compatibility: Defer_lock is part of the C++ standard library since C++11 and is widely supported
See also: std::defer_lock_t, std::unique_lock, std::lock_guard, std::mutex, std::try_to_lock, std::adopt_lock.
---