CoopSync for TBB 0.1.0
Cooperative synchronization primitives for TBB resumable tasks
Loading...
Searching...
No Matches
coopsync_tbb::mutex::scoped_lock Class Reference

RAII wrapper for mutex that acquires the mutex on construction and releases it on destruction. More...

#include <coopsync_tbb/mutex.hpp>

Public Member Functions

 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 ()
 Destroys the scoped_lock and releases the mutex.
 scoped_lock (const scoped_lock &)=delete
 scoped_lock is not copy-constructible.
scoped_lock & operator= (const scoped_lock &)=delete
 scoped_lock is not copy-assignable.
 scoped_lock (scoped_lock &&)=delete
 scoped_lock is not move-constructible.
scoped_lock & operator= (scoped_lock &&)=delete
 scoped_lock is not move-assignable.
void acquire (mutex &m)
 Acquires the mutex.
bool try_acquire (mutex &m)
 Attempts to acquire the mutex without blocking.
void release ()
 Releases the mutex. Does nothing if no mutex was previously acquired.

Detailed Description

RAII wrapper for mutex that acquires the mutex on construction and releases it on destruction.

Constructor & Destructor Documentation

◆ scoped_lock()

coopsync_tbb::mutex::scoped_lock::scoped_lock ( mutex & m)
explicit

Constructs a scoped_lock and acquires the given mutex.

Parameters
mThe mutex to acquire.

Member Function Documentation

◆ acquire()

void coopsync_tbb::mutex::scoped_lock::acquire ( mutex & m)

Acquires the mutex.

Parameters
mMutex to acquire.
Exceptions
std::system_errorif another mutex is already acquired.

◆ try_acquire()

bool coopsync_tbb::mutex::scoped_lock::try_acquire ( mutex & m)
nodiscard

Attempts to acquire the mutex without blocking.

Parameters
mMutex to acquire.
Returns
true if the mutex was successfully acquired, false otherwise.
Exceptions
std::system_errorif another mutex is already acquired.

The documentation for this class was generated from the following file: