nlib
nn::nlib::threading::UniqueLock< T > Class Template Referencefinal

Class to wrap objects like CriticalSection. More...

#include "nn/nlib/threading/CriticalSection.h"

Public Types

typedef T mutex_type
 T.
 
typedef mutex_type::native_handle_type native_handle_type
 mutex_type::native_handle_type.
 

Public Member Functions

void swap (UniqueLock &rhs) noexcept
 Attempts to swap the associated CriticalSection or other object. More...
 
void lock () NLIB_ACQUIRE()
 Locks the associated CriticalSection or other object.
 
void unlock () noexcept NLIB_RELEASE()
 Unlocks the associated CriticalSection or other object.
 
bool try_lock () noexcept NLIB_TRY_ACQUIRE(true)
 Attempts to lock the associated object like CriticalSection.
 
bool try_lock_for (const TimeSpan &timeout) noexcept NLIB_TRY_ACQUIRE(true)
 Attempts to lock with timeout the associated CriticalSection or other object.
 
bool try_lock_until (const DateTime &abstime) noexcept NLIB_TRY_ACQUIRE(true)
 Attempts to lock with timeout the associated CriticalSection or other object.
 
mutex_typerelease () noexcept NLIB_RETURN_CAPABILITY(*locker_)
 Removes the association. Does not unlock. More...
 
mutex_typemutex () const noexcept NLIB_RETURN_CAPABILITY(*locker_)
 Gets the pointer to the associated object like CriticalSection. More...
 
native_handle_type native_handle () NLIB_RETURN_CAPABILITY(*locker_)
 Returns an implementation-specific handle representing a lock.
 
bool owns_lock () const noexcept
 Returns true if the lock associated with UniqueLock is locked.
 
 operator bool () const
 Returns true if the lock is held.
 
Basic Member Functions
 UniqueLock () noexcept
 Initializes an object without creating an association.
 
 UniqueLock (mutex_type &rhs) NLIB_ACQUIRE(locker_)
 Locks the object like CriticalSection and associates it with this object. More...
 
 UniqueLock (mutex_type &rhs, AdoptLockType) NLIB_REQUIRES(locker_)
 Assumes an object like CriticalSection is already locked, and initializes the object without locking it. Unlocked in the destructor. More...
 
 UniqueLock (mutex_type &rhs, DeferLockType) noexcept NLIB_EXCLUDES(locker_)
 Initializes an object without locking. More...
 
 UniqueLock (mutex_type &rhs, TryToLockType)
 Attempts to lock using try_lock when initializing. More...
 
 UniqueLock (UniqueLock &&rhs) noexcept
 Instantiates the object (move constructor). This function is useful when using C++11.
 
UniqueLockoperator= (UniqueLock &&rhs) noexcept
 Move assignment operator. This function is useful when using C++11.
 
 UniqueLock (UniqueLock &rhs, move_tag) noexcept
 Corresponds to a move constructor.
 
UniqueLockassign (UniqueLock &rhs, move_tag) noexcept
 Corresponds to a move assignment operator.
 

Detailed Description

template<class T>
class nn::nlib::threading::UniqueLock< T >

Class to wrap objects like CriticalSection.

Template Parameters
TClasses such as CriticalSection.

Definition at line 311 of file CriticalSection.h.

Constructor & Destructor Documentation

◆ UniqueLock() [1/4]

template<class T >
nn::nlib::threading::UniqueLock< T >::UniqueLock ( mutex_type rhs)
inlineexplicit

Locks the object like CriticalSection and associates it with this object.

Parameters
[in]rhsObjects such as CriticalSection.

Definition at line 316 of file CriticalSection.h.

◆ UniqueLock() [2/4]

template<class T >
nn::nlib::threading::UniqueLock< T >::UniqueLock ( mutex_type rhs,
AdoptLockType   
)
inline

Assumes an object like CriticalSection is already locked, and initializes the object without locking it. Unlocked in the destructor.

Parameters
[in]rhsObjects such as CriticalSection.

Definition at line 320 of file CriticalSection.h.

◆ UniqueLock() [3/4]

template<class T >
nn::nlib::threading::UniqueLock< T >::UniqueLock ( mutex_type rhs,
DeferLockType   
)
inlinenoexcept

Initializes an object without locking.

Parameters
[in]rhsObjects such as CriticalSection.

Definition at line 322 of file CriticalSection.h.

◆ UniqueLock() [4/4]

template<class T >
nn::nlib::threading::UniqueLock< T >::UniqueLock ( mutex_type rhs,
TryToLockType   
)
inline

Attempts to lock using try_lock when initializing.

Parameters
[in]rhsObjects such as CriticalSection.

Definition at line 325 of file CriticalSection.h.

Member Function Documentation

◆ mutex()

template<class T >
nn::nlib::threading::UniqueLock< T >::mutex ( ) const
inlinenoexcept

Gets the pointer to the associated object like CriticalSection.

Returns
Pointer to the object associated, such as CriticalSection.

Definition at line 411 of file CriticalSection.h.

◆ release()

template<class T >
nn::nlib::threading::UniqueLock< T >::release ( )
inlinenoexcept

Removes the association. Does not unlock.

Returns
Pointer to the object associated, such as CriticalSection.

Definition at line 405 of file CriticalSection.h.

◆ swap()

template<class T >
nn::nlib::threading::UniqueLock< T >::swap ( UniqueLock< T > &  rhs)
inlinenoexcept

Attempts to swap the associated CriticalSection or other object.

Parameters
[in]rhsObject to swap.
Deprecated:
This function will be deleted in a future release.

Definition at line 357 of file CriticalSection.h.


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