roo_threads
API Documentation for roo_threads
Loading...
Searching...
No Matches
roo_threads::doc::unique_lock< Mutex > Class Template Reference

#include <mutex_api.h>

Public Types

using mutex_type = Mutex
 Type of wrapped mutex.
 

Public Member Functions

 unique_lock () noexcept
 Constructs an empty lock not associated with any mutex.
 
 unique_lock (mutex_type &mutex)
 Acquires the given mutex.
 
 unique_lock (mutex_type &mutex, defer_lock_t) noexcept
 Associates with mutex but does not lock it.
 
 unique_lock (mutex_type &mutex, try_to_lock_t)
 Attempts to lock mutex without blocking.
 
 unique_lock (mutex_type &mutex, adopt_lock_t) noexcept
 Adopts an already-owned mutex.
 
 unique_lock (mutex_type &mutex, roo_time::Uptime tp)
 Attempts to lock until the specified time point.
 
 unique_lock (mutex_type &mutex, roo_time::Duration duration)
 Attempts to lock for the specified duration.
 
 ~unique_lock ()
 Releases owned mutex if any.
 
 unique_lock (const unique_lock &)=delete
 
unique_lockoperator= (const unique_lock &)=delete
 
 unique_lock (unique_lock &&lock) noexcept
 Move-constructs the lock.
 
unique_lockoperator= (unique_lock &&lock) noexcept
 Move-assigns the lock.
 
void lock ()
 Acquires associated mutex.
 
bool try_lock ()
 Attempts to acquire associated mutex without blocking.
 
bool try_lock_until (roo_time::Uptime tp)
 Attempts to acquire associated mutex before the given deadline.
 
bool try_lock_for (roo_time::Duration duration)
 Attempts to acquire associated mutex for the given duration.
 
void unlock ()
 Releases associated mutex if owned.
 
void swap (unique_lock &other) noexcept
 Swaps two locks.
 
mutex_typerelease () noexcept
 Disassociates lock from mutex without unlocking.
 
bool owns_lock () const noexcept
 Returns whether this lock currently owns the mutex.
 
 operator bool () const noexcept
 Boolean conversion equivalent to owns_lock().
 
mutex_typemutex () const noexcept
 Returns associated mutex pointer, or nullptr.
 

Detailed Description

template<typename Mutex>
class roo_threads::doc::unique_lock< Mutex >

Definition at line 60 of file mutex_api.h.

Member Typedef Documentation

◆ mutex_type

Type of wrapped mutex.

Definition at line 63 of file mutex_api.h.

Constructor & Destructor Documentation

◆ unique_lock() [1/9]

template<typename Mutex >
roo_threads::doc::unique_lock< Mutex >::unique_lock ( )
noexcept

Constructs an empty lock not associated with any mutex.

◆ unique_lock() [2/9]

template<typename Mutex >
roo_threads::doc::unique_lock< Mutex >::unique_lock ( mutex_type mutex)
explicit

Acquires the given mutex.

Parameters
mutexmutex to lock.

◆ unique_lock() [3/9]

template<typename Mutex >
roo_threads::doc::unique_lock< Mutex >::unique_lock ( mutex_type mutex,
defer_lock_t   
)
noexcept

Associates with mutex but does not lock it.

Parameters
mutexmutex to associate with.

◆ unique_lock() [4/9]

template<typename Mutex >
roo_threads::doc::unique_lock< Mutex >::unique_lock ( mutex_type mutex,
try_to_lock_t   
)

Attempts to lock mutex without blocking.

Parameters
mutexmutex to lock.

◆ unique_lock() [5/9]

template<typename Mutex >
roo_threads::doc::unique_lock< Mutex >::unique_lock ( mutex_type mutex,
adopt_lock_t   
)
noexcept

Adopts an already-owned mutex.

Parameters
mutexmutex already locked by caller.

◆ unique_lock() [6/9]

template<typename Mutex >
roo_threads::doc::unique_lock< Mutex >::unique_lock ( mutex_type mutex,
roo_time::Uptime  tp 
)

Attempts to lock until the specified time point.

Parameters
mutexmutex to lock.
tpabsolute timeout point.

◆ unique_lock() [7/9]

template<typename Mutex >
roo_threads::doc::unique_lock< Mutex >::unique_lock ( mutex_type mutex,
roo_time::Duration  duration 
)

Attempts to lock for the specified duration.

Parameters
mutexmutex to lock.
durationrelative timeout duration.

◆ ~unique_lock()

Releases owned mutex if any.

◆ unique_lock() [8/9]

template<typename Mutex >
roo_threads::doc::unique_lock< Mutex >::unique_lock ( const unique_lock< Mutex > &  )
delete

◆ unique_lock() [9/9]

template<typename Mutex >
roo_threads::doc::unique_lock< Mutex >::unique_lock ( unique_lock< Mutex > &&  lock)
noexcept

Move-constructs the lock.

Member Function Documentation

◆ lock()

Acquires associated mutex.

◆ mutex()

template<typename Mutex >
mutex_type * roo_threads::doc::unique_lock< Mutex >::mutex ( ) const
noexcept

Returns associated mutex pointer, or nullptr.

◆ operator bool()

template<typename Mutex >
roo_threads::doc::unique_lock< Mutex >::operator bool ( ) const
explicitnoexcept

Boolean conversion equivalent to owns_lock().

◆ operator=() [1/2]

◆ operator=() [2/2]

Move-assigns the lock.

Returns
reference to this object.

◆ owns_lock()

template<typename Mutex >
bool roo_threads::doc::unique_lock< Mutex >::owns_lock ( ) const
noexcept

Returns whether this lock currently owns the mutex.

◆ release()

template<typename Mutex >
mutex_type * roo_threads::doc::unique_lock< Mutex >::release ( )
noexcept

Disassociates lock from mutex without unlocking.

Returns
pointer to previously associated mutex.

◆ swap()

template<typename Mutex >
void roo_threads::doc::unique_lock< Mutex >::swap ( unique_lock< Mutex > &  other)
noexcept

Swaps two locks.

◆ try_lock()

template<typename Mutex >
bool roo_threads::doc::unique_lock< Mutex >::try_lock ( )

Attempts to acquire associated mutex without blocking.

Returns
true if lock acquired.

◆ try_lock_for()

template<typename Mutex >
bool roo_threads::doc::unique_lock< Mutex >::try_lock_for ( roo_time::Duration  duration)

Attempts to acquire associated mutex for the given duration.

Parameters
durationrelative timeout duration.
Returns
true if lock acquired.

◆ try_lock_until()

template<typename Mutex >
bool roo_threads::doc::unique_lock< Mutex >::try_lock_until ( roo_time::Uptime  tp)

Attempts to acquire associated mutex before the given deadline.

Parameters
tpabsolute timeout point.
Returns
true if lock acquired.

◆ unlock()

Releases associated mutex if owned.


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