riot::unique_lock< Mutex > Class Template Reference

C++11 compliant implementation of unique lock. More...

Detailed Description

template<class Mutex>
class riot::unique_lock< Mutex >

C++11 compliant implementation of unique lock.

See also
std::unique_lock

Definition at line 142 of file mutex.hpp.

#include <mutex.hpp>

Public Types

using mutex_type = Mutex
 The type of Mutex used by the lock.
 

Public Member Functions

 unique_lock (mutex_type &mtx)
 Constructs a unique_lock from a Mutex and locks it.
 
 unique_lock (mutex_type &mtx, defer_lock_t) noexcept
 Constructs a unique_lock from a Mutex but does not lock it.
 
 unique_lock (mutex_type &mtx, try_to_lock_t)
 Constructs a unique_lock from a Mutex and tries to lock it.
 
 unique_lock (mutex_type &mtx, adopt_lock_t)
 Constructs a unique_lock from a Mutex that is already owned by the thread.
 
 unique_lock (unique_lock &&lock) noexcept
 Move constructor.
 
unique_lockoperator= (unique_lock &&lock) noexcept
 Move assignment operator.
 
void lock ()
 Locks the associated mutex.
 
bool try_lock ()
 Tries to lock the associated mutex. More...
 
void unlock ()
 Unlocks the associated mutex.
 
void swap (unique_lock &lock) noexcept
 Swap this unique_lock with another unique_lock.
 
mutex_typerelease () noexcept
 Disassociate this lock from its mutex. More...
 
bool owns_lock () const noexcept
 Query ownership of the associate mutex. More...
 
 operator bool () const noexcept
 Operator to query the ownership of the associated mutex. More...
 
mutex_typemutex () const noexcept
 Provides access to the associated mutex. More...
 

Member Function Documentation

◆ mutex()

template<class Mutex >
mutex_type* riot::unique_lock< Mutex >::mutex ( ) const
inlinenoexcept

Provides access to the associated mutex.

Returns
A pointer to the associated mutex or nullptr it there was none.

Definition at line 250 of file mutex.hpp.

◆ operator bool()

template<class Mutex >
riot::unique_lock< Mutex >::operator bool ( ) const
inlineexplicitnoexcept

Operator to query the ownership of the associated mutex.

Returns
true if an associated mutex exists and the lock owns it, false otherwise.

Definition at line 245 of file mutex.hpp.

◆ owns_lock()

template<class Mutex >
bool riot::unique_lock< Mutex >::owns_lock ( ) const
inlinenoexcept

Query ownership of the associate mutex.

Returns
true if an associated mutex exists and the lock owns it, false otherwise.

Definition at line 239 of file mutex.hpp.

◆ release()

template<class Mutex >
mutex_type* riot::unique_lock< Mutex >::release ( )
inlinenoexcept

Disassociate this lock from its mutex.

The caller is responsible to unlock the mutex if it was locked before.

Returns
A pointer to the associated mutex or nullptr if there was none.

Definition at line 227 of file mutex.hpp.

◆ try_lock()

template<class Mutex >
bool riot::unique_lock< Mutex >::try_lock

Tries to lock the associated mutex.

Returns
true if the mutex has been locked successfully, false otherwise.

Definition at line 277 of file mutex.hpp.


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