Async++ unknown
Async (co_await/co_return) code for C++
Loading...
Searching...
No Matches
asyncpp::mutex_lock Class Reference

RAII type to automatically unlock a mutex once it leaves scope. More...

#include <asyncpp/mutex.h>

Public Member Functions

 mutex_lock (class mutex &mtx, std::adopt_lock_t) noexcept
 Construct a mutex_lock for the given mutex, adopting the lock.
 
constexpr mutex_lock (class mutex &mtx) noexcept
 Construct an unlocked mutex_lock for the given mutex.
 
constexpr mutex_lock (const mutex_lock &) noexcept=delete
 
constexpr mutex_lockoperator= (const mutex_lock &) noexcept=delete
 
constexpr mutex_lock (mutex_lock &&other) noexcept
 
mutex_lockoperator= (mutex_lock &&other) noexcept
 
void unlock () noexcept
 Unlock the lock See mutex::unlock() for details.
 
bool try_lock () noexcept
 Try locking the contained mutex.
 
auto lock () noexcept
 Asynchronously lock the contained mutex.
 
bool is_locked () const noexcept
 Check if the mutex is held by this lock.
 
class mutexmutex () const noexcept
 Get the wrapped mutex.
 

Detailed Description

RAII type to automatically unlock a mutex once it leaves scope.

Constructor & Destructor Documentation

◆ mutex_lock() [1/2]

asyncpp::mutex_lock::mutex_lock ( class mutex & mtx,
std::adopt_lock_t  )
inlinenoexcept

Construct a mutex_lock for the given mutex, adopting the lock.

Note
Behaviour is undefined if the supplied mutex has not been locked (e.g. using try_lock()).

◆ mutex_lock() [2/2]

constexpr asyncpp::mutex_lock::mutex_lock ( class mutex & mtx)
inlineexplicitconstexprnoexcept

Construct an unlocked mutex_lock for the given mutex.

Note
Unlike std::lock_guard/unique_lock, the mutex is not locked by the constructor.

Member Function Documentation

◆ lock()

auto asyncpp::mutex_lock::lock ( )
inlinenoexcept

Asynchronously lock the contained mutex.

See mutex::lock() for details.

◆ try_lock()

bool asyncpp::mutex_lock::try_lock ( )
inlinenoexcept

Try locking the contained mutex.

See mutex::try_lock() for details.


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