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

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 lock ()
 Locks the associated CriticalSection or other object.
 
void unlock () noexcept
 Unlocks the associated CriticalSection or other object.
 
bool try_lock () noexcept
 Attempts to lock the associated object like CriticalSection.
 
bool try_lock_for (const TimeSpan &timeout) noexcept
 Attempts to lock with timeout the associated CriticalSection or other object.
 
bool try_lock_until (const DateTime &abstime) noexcept
 Attempts to lock with timeout the associated CriticalSection or other object.
 
void swap (UniqueLock &rhs) noexcept
 Attempts to swap the associated CriticalSection or other object. More...
 
mutex_typerelease () noexcept
 Removes the association. Does not unlock. More...
 
mutex_typemutex () const noexcept
 Gets the pointer to the associated object like CriticalSection. More...
 
native_handle_type native_handle ()
 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)
 Locks the object like CriticalSection and associates it with this object. More...
 
 UniqueLock (mutex_type &rhs, AdoptLockType)
 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
 Initializes an object without locking. More...
 
 UniqueLock (mutex_type &rhs, TryToLockType)
 Attempts to lock using try_lock when initializing. More...
 
UniqueLockassign (UniqueLock &rhs, move_tag)
 Assigns the object by using swap for a move.
 
 UniqueLock (UniqueLock &rhs, move_tag)
 Instantiates the object by using swap for a move.
 
 UniqueLock (UniqueLock &&rhs)
 Instantiates the object (move constructor). This function is useful when using C++11.
 
UniqueLockoperator= (UniqueLock &&rhs)
 Move assignment operator. This function is useful when using C++11.
 

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 275 of file CriticalSection.h.

Constructor & Destructor Documentation

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 280 of file CriticalSection.h.

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 283 of file CriticalSection.h.

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 286 of file CriticalSection.h.

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 289 of file CriticalSection.h.

Member Function Documentation

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 347 of file CriticalSection.h.

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 341 of file CriticalSection.h.

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.

Definition at line 336 of file CriticalSection.h.


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