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

Class for handling thread local storage. More...

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

Public Member Functions

constexpr Tls () noexcept
 Instantiates the object with default parameters (default constructor).
 
errno_t Init () noexcept
 Initializes thread local storage. More...
 
 ~Tls () noexcept
 Destructor. The pointer will be deleted.
 
T * Get () const noexcept
 Gets a pointer to the specified thread. More...
 
T * operator-> () const noexcept
 Returns the pointer.
 
T & operator* () const noexcept
 Dereferences the pointer.
 
T * Release () noexcept
 Releases the pointer to the specified thread. More...
 
errno_t Reset (T *p=0) noexcept
 Releases the pointer to the specified thread. More...
 

Detailed Description

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

Class for handling thread local storage.

Template Parameters
TType of object storing the pointer.
Description
This class wraps nlib_tls.

Definition at line 25 of file Tls.h.

Member Function Documentation

◆ Get()

template<class T >
nn::nlib::threading::Tls< T >::Get ( ) const
inlinenoexcept

Gets a pointer to the specified thread.

Returns
Pointer to the object of type T.

Definition at line 40 of file Tls.h.

◆ Init()

template<class T >
nn::nlib::threading::Tls< T >::Init ( )
inlinenoexcept

Initializes thread local storage.

Return values
0Initialization was successful.
ENOMEMIndicates that there are not enough system resources.
Description
Run once before using thread local storage.

Definition at line 28 of file Tls.h.

◆ Release()

template<class T >
nn::nlib::threading::Tls< T >::Release ( )
inlinenoexcept

Releases the pointer to the specified thread.

Returns
Pointer to the object of type T.
Description
The pointer will no longer be controlled by Tls after running the function.

Definition at line 48 of file Tls.h.

◆ Reset()

template<class T >
nn::nlib::threading::Tls< T >::Reset ( T *  p = 0)
inlinenoexcept

Releases the pointer to the specified thread.

Parameters
[in]pPointer to the object allocated by new.
Return values
0Initialization was successful.
ENOMEMIndicates that there are not enough system resources.
Description
The pointer held by Tls is deleted, and p is replaced.

Definition at line 53 of file Tls.h.


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