![]() |
BRICKS
Small, useful blocks of code, to build bigger things.
|
A mutual exclusion primitive that can be used to protect shared data. More...
#include <mutex.hpp>
Public Types | |
using | value_type = Class |
using | lock_guard = detail::write_guard<mutex, std::mutex> |
using | const_lock_guard = detail::write_guard<const mutex, std::mutex> |
Public Member Functions | |
auto | lock () noexcept -> lock_guard |
Locks the mutex, blocking until the lock is acquired. | |
auto | lock () const noexcept -> const_lock_guard |
Friends | |
class | detail::write_guard< mutex, std::mutex > |
class | detail::write_guard< const mutex, std::mutex > |
A mutual exclusion primitive that can be used to protect shared data.
This mutex will block threads waiting for the lock to become available. The mutex can be created by passing the data to be protected to the constructor. The data can be accessed by calling the lock()
method, which returns a RAII style lock guard. The lock guard can be used to access the protected data.
Example usage:
using bricks::mutex< Class, >::const_lock_guard = detail::write_guard<const mutex, std::mutex> |
using bricks::mutex< Class, >::lock_guard = detail::write_guard<mutex, std::mutex> |
using bricks::mutex< Class, >::value_type = Class |
|
inlinenoexcept |
|
inlinenoexcept |
Locks the mutex, blocking until the lock is acquired.
|
friend |
|
friend |