A shared mutex that can be used to synchronize access to shared resources. The mutex can be acquired in exclusive (writer) mode (lock) or shared (reader) mode (lock_shared). The mutex is non-recursive and provides no fairness guarantees.
More...
#include <coopsync_tbb/shared_mutex.hpp>
|
| class | scoped_lock |
| | RAII wrapper for mutex that acquires the mutex on construction and releases it on destruction. More...
|
|
|
static constexpr bool | is_rw_mutex = true |
| | The shared_mutex is a reader-writer (shared) mutex.
|
|
static constexpr bool | is_recursive_mutex = false |
| | The shared_mutex is not recursive.
|
|
static constexpr bool | is_fair_mutex = false |
| | The shared_mutex does not provide any fairness guarantees.
|
A shared mutex that can be used to synchronize access to shared resources. The mutex can be acquired in exclusive (writer) mode (lock) or shared (reader) mode (lock_shared). The mutex is non-recursive and provides no fairness guarantees.
- Note
- This mutex does satisfy the standard named requirements for BasicLockable and Lockable but does not meet the requirements for Mutex because it never blocks the calling thread, even though it exposes the same interface. Concurrent invocations of the member functions, except for destructor, are safe.
◆ ~shared_mutex()
| coopsync_tbb::shared_mutex::~shared_mutex |
( |
| ) |
|
Destroys the shared_mutex.
- Note
- The destructor must not be called while the shared_mutex is still locked or while there are tasks suspended on it. The destructor does not notify or resume any waiting tasks.
◆ lock()
| void coopsync_tbb::shared_mutex::lock |
( |
| ) |
|
Acquires the shared_mutex, suspending the calling task if necessary until the shared_mutex becomes available.
- Note
- The suspended task must remain valid until it is resumed.
-
The suspended task must be resumed before the shared_mutex is destroyed.
◆ lock_shared()
| void coopsync_tbb::shared_mutex::lock_shared |
( |
| ) |
|
Acquires the shared_mutex in a shared mode, suspending the calling task if necessary until the shared_mutex becomes available in shared mode.
- Note
- The suspended task must remain valid until it is resumed.
-
The suspended task must be resumed before the shared_mutex is destroyed.
◆ try_lock()
| bool coopsync_tbb::shared_mutex::try_lock |
( |
| ) |
|
|
nodiscardnoexcept |
Attempts to acquire the shared_mutex without suspending.
- Returns
- true if the shared_mutex was successfully acquired, false otherwise.
◆ try_lock_shared()
| bool coopsync_tbb::shared_mutex::try_lock_shared |
( |
| ) |
|
|
nodiscardnoexcept |
Attempts to acquire the shared_mutex in a shared mode without suspending.
- Returns
- true if the shared_mutex was successfully acquired in shared mode, false otherwise.
The documentation for this class was generated from the following file: