Loading...
Searching...
No Matches
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.
 
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.
 
bool owns_lock () const noexcept
 Query ownership of the associate mutex.
 
 operator bool () const noexcept
 Operator to query the ownership of the associated mutex.
 
mutex_typemutex () const noexcept
 Provides access to the associated mutex.
 

Member Typedef Documentation

◆ mutex_type

template<class Mutex >
using riot::unique_lock< Mutex >::mutex_type = Mutex

The type of Mutex used by the lock.

Definition at line 147 of file mutex.hpp.

Constructor & Destructor Documentation

◆ unique_lock() [1/6]

template<class Mutex >
riot::unique_lock< Mutex >::unique_lock ( )
inlinenoexcept

Definition at line 149 of file mutex.hpp.

◆ unique_lock() [2/6]

template<class Mutex >
riot::unique_lock< Mutex >::unique_lock ( mutex_type mtx)
inlineexplicit

Constructs a unique_lock from a Mutex and locks it.

Definition at line 153 of file mutex.hpp.

◆ unique_lock() [3/6]

template<class Mutex >
riot::unique_lock< Mutex >::unique_lock ( mutex_type mtx,
defer_lock_t   
)
inlinenoexcept

Constructs a unique_lock from a Mutex but does not lock it.

Definition at line 159 of file mutex.hpp.

◆ unique_lock() [4/6]

template<class Mutex >
riot::unique_lock< Mutex >::unique_lock ( mutex_type mtx,
try_to_lock_t   
)
inline

Constructs a unique_lock from a Mutex and tries to lock it.

Definition at line 164 of file mutex.hpp.

◆ unique_lock() [5/6]

template<class Mutex >
riot::unique_lock< Mutex >::unique_lock ( mutex_type mtx,
adopt_lock_t   
)
inline

Constructs a unique_lock from a Mutex that is already owned by the thread.

Definition at line 170 of file mutex.hpp.

◆ ~unique_lock()

template<class Mutex >
riot::unique_lock< Mutex >::~unique_lock ( )
inline

Definition at line 172 of file mutex.hpp.

◆ unique_lock() [6/6]

template<class Mutex >
riot::unique_lock< Mutex >::unique_lock ( unique_lock< Mutex > &&  lock)
inlinenoexcept

Move constructor.

Definition at line 180 of file mutex.hpp.

Member Function Documentation

◆ lock()

template<class Mutex >
void riot::unique_lock< Mutex >::lock ( )

Locks the associated mutex.

Definition at line 261 of file mutex.hpp.

◆ 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.

◆ operator=()

template<class Mutex >
unique_lock & riot::unique_lock< Mutex >::operator= ( unique_lock< Mutex > &&  lock)
inlinenoexcept

Move assignment operator.

Definition at line 188 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.

◆ swap()

template<class Mutex >
void riot::unique_lock< Mutex >::swap ( unique_lock< Mutex > &  lock)
inlinenoexcept

Swap this unique_lock with another unique_lock.

Definition at line 217 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.

◆ unlock()

template<class Mutex >
void riot::unique_lock< Mutex >::unlock ( )

Unlocks the associated mutex.

Definition at line 293 of file mutex.hpp.


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