std::lock_guard
From cppreference.com
Defined in header <mutex>
|
||
template< class Mutex > class lock_guard; |
(since C++11) | |
The class lock_guard implements a strictly scope-based mutex ownership wrapper. The class is non-copyable. The supplied Mutex type shall implement the Lockable concept.
This section is incomplete |
[edit] Member types
Member type | Definition |
mutex_type | Mutex |
[edit] Member functions
constructs new lock_guard object and locks the given mutex (public member function) | |
destructs the lock_guard object, unlocks the underlying mutex (public member function) |
[edit] Example
std::mutex m; void do_something() { std::lock_guard<std::mutex> lock(m); // the remaining function is thread-safe now }