RAII wrapper for mutex that acquires the mutex on construction and releases it on destruction.
More...
#include <coopsync_tbb/shared_mutex.hpp>
RAII wrapper for mutex that acquires the mutex on construction and releases it on destruction.
◆ scoped_lock()
| coopsync_tbb::shared_mutex::scoped_lock::scoped_lock |
( |
shared_mutex & | m, |
|
|
bool | write = true ) |
|
explicit |
Constructs a scoped_lock and acquires the given mutex.
- Parameters
-
| m | The mutex to acquire. |
| write | If true, acquires the mutex in exclusive (writer) mode. If false, acquires the mutex in shared (reader) mode. |
◆ acquire()
| void coopsync_tbb::shared_mutex::scoped_lock::acquire |
( |
shared_mutex & | m, |
|
|
bool | write = true ) |
Acquires the mutex.
- Parameters
-
| m | Mutex to acquire. |
| write | If true, acquires the mutex in exclusive (writer) mode. If false, acquires the mutex in shared (reader) mode. |
- Exceptions
-
| std::system_error | if another mutex is already acquired. |
◆ downgrade_to_reader()
| bool coopsync_tbb::shared_mutex::scoped_lock::downgrade_to_reader |
( |
| ) |
|
Changes a reader lock to a writer lock.
- Returns
- false if the lock was released and reacquired. Otherwise, return true.
- Exceptions
-
| std::system_error | if no mutex was previously acquired. |
◆ try_acquire()
| bool coopsync_tbb::shared_mutex::scoped_lock::try_acquire |
( |
shared_mutex & | m, |
|
|
bool | write = true ) |
|
nodiscard |
Attempts to acquire the mutex without blocking.
- Parameters
-
| m | Mutex to acquire. |
| write | If true, attempts to acquire the mutex in exclusive (writer) mode. If false, attempts to acquire the mutex in shared (reader) mode. |
- Returns
- true if the mutex was successfully acquired, false otherwise.
- Exceptions
-
| std::system_error | if another mutex is already acquired. |
◆ upgrade_to_writer()
| bool coopsync_tbb::shared_mutex::scoped_lock::upgrade_to_writer |
( |
| ) |
|
Changes a writer lock to a reader lock.
- Returns
- false if the lock was released and reacquired. Otherwise, return true.
- Exceptions
-
| std::system_error | if no mutex was previously acquired. |
The documentation for this class was generated from the following file: