9#include "coopsync_tbb/detail/macros.hpp"
10#include "coopsync_tbb/detail/wait_queue.hpp"
23class COOPSYNC_TBB_EXPORT
mutex {
51 COOPSYNC_TBB_NODISCARD
bool try_lock() noexcept;
71 std::atomic<
bool> m_locked = {
false};
72 detail::wait_queue m_wait_queue;
RAII wrapper for mutex that acquires the mutex on construction and releases it on destruction.
Definition mutex.hpp:77
scoped_lock(const scoped_lock &)=delete
scoped_lock is not copy-constructible.
~scoped_lock()
Destroys the scoped_lock and releases the mutex.
void acquire(mutex &m)
Acquires the mutex.
scoped_lock()
Constructs a scoped_lock without acquiring a mutex.
scoped_lock(mutex &m)
Constructs a scoped_lock and acquires the given mutex.
scoped_lock & operator=(scoped_lock &&)=delete
scoped_lock is not move-assignable.
scoped_lock(scoped_lock &&)=delete
scoped_lock is not move-constructible.
bool try_acquire(mutex &m)
Attempts to acquire the mutex without blocking.
scoped_lock & operator=(const scoped_lock &)=delete
scoped_lock is not copy-assignable.
void release()
Releases the mutex. Does nothing if no mutex was previously acquired.
void unlock()
Releases the mutex. If there are tasks suspended on the mutex, exactly one of them is resumed and acq...
mutex(const mutex &)=delete
The mutex is not copy-constructible.
static constexpr bool is_fair_mutex
The mutex does not provide any fairness guarantees.
Definition mutex.hpp:68
static constexpr bool is_recursive_mutex
The mutex is not recursive.
Definition mutex.hpp:66
mutex()=default
Constructs a new mutex. The mutex is initially unlocked.
static constexpr bool is_rw_mutex
The mutex is not a reader-writer (shared) mutex.
Definition mutex.hpp:64
mutex & operator=(const mutex &)=delete
The mutex is not copy-assignable.
mutex(mutex &&)=delete
The mutex is not move-constructible.
void lock()
Acquires the mutex, suspending the calling task if necessary until the mutex becomes available.
bool try_lock() noexcept
Attempts to acquire the mutex without suspending.
mutex & operator=(mutex &&)=delete
Mutex is not move-assignable.
~mutex()
Destroys the mutex.
Main namespace of the library, containing all public APIs.
Definition wait_for.hpp:11