aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::ThreadData< T_DATA > Class Template Reference

A wrapper that enables to store data in a way that prevents false cacheline sharing. More...

#include <agrum/base/core/threads/threadData.h>

Public Types

using data_type = std::conditional< std::is_scalar< T_DATA >::value, T_DATA, T_DATA& >
 the return types of accessors: T_DATA if scalar, else T_DATA&

Public Member Functions

Constructors / Destructors
 ThreadData (const T_DATA &theData)
 default constructor
 ThreadData (T_DATA &&theData)
 default constructor
 ThreadData (const ThreadData< T_DATA > &from)
 copy constructor
 ThreadData (ThreadData< T_DATA > &&from)
 move constructor
 ~ThreadData ()
 destructor
Operators
ThreadData< T_DATA > & operator= (const ThreadData< T_DATA > &from)
 copy operator
ThreadData< T_DATA > & operator= (ThreadData< T_DATA > &&from)
 move operator
bool operator== (const ThreadData< T_DATA > &from)
 equality operator
bool operator== (const T_DATA &from)
 equality operator
bool operator!= (const ThreadData< T_DATA > &from)
 inequality operator
bool operator!= (const T_DATA &from)
 inequality operator

Accessors

using data_pointer
 the data we wish to store without cacheline parallel problem
T_DATA data
 the data we wish to store without cacheline parallel problem
data_type operator* ()
 easy accessor
template<typename X = T_DATA>
std::enable_if_t< std::is_pointer< X >::value, data_pointeroperator-> ()
 the data we wish to store without cacheline parallel problem
template<typename X = T_DATA>
std::enable_if_t< !std::is_pointer< X >::value, data_pointeroperator-> ()
 the data we wish to store without cacheline parallel problem

Detailed Description

template<typename T_DATA>
class gum::ThreadData< T_DATA >

A wrapper that enables to store data in a way that prevents false cacheline sharing.

When several threads access to some shared containers like vectors, it may be the case that they access some data within these containers that are too close, which results in false sharing of the cacheline. By wrapping the data into a ThreadData, we guarantee that no false sharing can occur.

To create a wrapper data, simply use wrapped_data = ThreadData (data) and To get the data wrapped, use wrapped_data.data;

Definition at line 77 of file threadData.h.

Member Typedef Documentation

◆ data_pointer

template<typename T_DATA>
using gum::ThreadData< T_DATA >::data_pointer
Initial value:
typename std::conditional< std::is_pointer< T_DATA >::value,
T_DATA,
typename std::add_pointer< T_DATA >::type >::type

the data we wish to store without cacheline parallel problem

Definition at line 144 of file threadData.h.

◆ data_type

template<typename T_DATA>
using gum::ThreadData< T_DATA >::data_type = std::conditional< std::is_scalar< T_DATA >::value, T_DATA, T_DATA& >

the return types of accessors: T_DATA if scalar, else T_DATA&

Definition at line 79 of file threadData.h.

Constructor & Destructor Documentation

◆ ThreadData() [1/4]

template<typename T_DATA>
gum::ThreadData< T_DATA >::ThreadData ( const T_DATA & theData)
inline

default constructor

Definition at line 87 of file threadData.h.

87: data(theData) {}
A wrapper that enables to store data in a way that prevents false cacheline sharing.
Definition threadData.h:77
T_DATA data
the data we wish to store without cacheline parallel problem
Definition threadData.h:160

References data.

Referenced by ThreadData(), ThreadData(), operator!=(), operator=(), operator=(), and operator==().

Here is the caller graph for this function:

◆ ThreadData() [2/4]

template<typename T_DATA>
gum::ThreadData< T_DATA >::ThreadData ( T_DATA && theData)
inline

default constructor

Definition at line 90 of file threadData.h.

References data.

◆ ThreadData() [3/4]

template<typename T_DATA>
gum::ThreadData< T_DATA >::ThreadData ( const ThreadData< T_DATA > & from)
inline

copy constructor

Definition at line 93 of file threadData.h.

93: data(from.data) {}

References ThreadData(), and data.

Here is the call graph for this function:

◆ ThreadData() [4/4]

template<typename T_DATA>
gum::ThreadData< T_DATA >::ThreadData ( ThreadData< T_DATA > && from)
inline

move constructor

Definition at line 96 of file threadData.h.

References ThreadData(), and data.

Here is the call graph for this function:

◆ ~ThreadData()

template<typename T_DATA>
gum::ThreadData< T_DATA >::~ThreadData ( )
inline

destructor

Definition at line 99 of file threadData.h.

99{}

Member Function Documentation

◆ operator!=() [1/2]

template<typename T_DATA>
bool gum::ThreadData< T_DATA >::operator!= ( const T_DATA & from)
inline

inequality operator

Definition at line 131 of file threadData.h.

131{ return data != from; }

References data.

◆ operator!=() [2/2]

template<typename T_DATA>
bool gum::ThreadData< T_DATA >::operator!= ( const ThreadData< T_DATA > & from)
inline

inequality operator

Definition at line 128 of file threadData.h.

128{ return data != from.data; }

References ThreadData(), and data.

Here is the call graph for this function:

◆ operator*()

template<typename T_DATA>
data_type gum::ThreadData< T_DATA >::operator* ( )
inline

easy accessor

Definition at line 142 of file threadData.h.

142{ return data; }

References data.

◆ operator->() [1/2]

template<typename T_DATA>
template<typename X = T_DATA>
std::enable_if_t< !std::is_pointer< X >::value, data_pointer > gum::ThreadData< T_DATA >::operator-> ( )
inline

the data we wish to store without cacheline parallel problem

Definition at line 155 of file threadData.h.

155 {
156 return &data;
157 }

References data.

◆ operator->() [2/2]

template<typename T_DATA>
template<typename X = T_DATA>
std::enable_if_t< std::is_pointer< X >::value, data_pointer > gum::ThreadData< T_DATA >::operator-> ( )
inline

the data we wish to store without cacheline parallel problem

Definition at line 150 of file threadData.h.

150 {
151 return data;
152 }

References data.

◆ operator=() [1/2]

template<typename T_DATA>
ThreadData< T_DATA > & gum::ThreadData< T_DATA >::operator= ( const ThreadData< T_DATA > & from)
inline

copy operator

Definition at line 110 of file threadData.h.

110 {
111 data = from.data;
112 return *this;
113 }

References ThreadData(), and data.

Here is the call graph for this function:

◆ operator=() [2/2]

template<typename T_DATA>
ThreadData< T_DATA > & gum::ThreadData< T_DATA >::operator= ( ThreadData< T_DATA > && from)
inline

move operator

Definition at line 116 of file threadData.h.

116 {
118 return *this;
119 }

References ThreadData(), and data.

Here is the call graph for this function:

◆ operator==() [1/2]

template<typename T_DATA>
bool gum::ThreadData< T_DATA >::operator== ( const T_DATA & from)
inline

equality operator

Definition at line 125 of file threadData.h.

125{ return data == from; }

References data.

◆ operator==() [2/2]

template<typename T_DATA>
bool gum::ThreadData< T_DATA >::operator== ( const ThreadData< T_DATA > & from)
inline

equality operator

Definition at line 122 of file threadData.h.

122{ return data == from.data; }

References ThreadData(), and data.

Here is the call graph for this function:

Member Data Documentation

◆ data

template<typename T_DATA>
T_DATA gum::ThreadData< T_DATA >::data

the data we wish to store without cacheline parallel problem

Definition at line 160 of file threadData.h.

Referenced by ThreadData(), ThreadData(), ThreadData(), ThreadData(), operator!=(), operator!=(), operator*(), operator->(), operator=(), operator=(), operator==(), and operator==().


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