aGrUM  0.20.3
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/tools/core/threadData.h>

Public Attributes

T_DATA data
 the data we wish to store without cacheline parallel problem More...
 

Public Member Functions

Constructors / Destructors
 ThreadData (const T_DATA &theData)
 default constructor More...
 
 ThreadData (T_DATA &&theData)
 default constructor More...
 
 ThreadData (const ThreadData< T_DATA > &from)
 copy constructor More...
 
 ThreadData (ThreadData< T_DATA > &&from)
 move constructor More...
 
 ~ThreadData ()
 destructor More...
 
Operators
ThreadData< T_DATA > & operator= (const ThreadData< T_DATA > &from)
 copy operator More...
 
ThreadData< T_DATA > & operator= (ThreadData< T_DATA > &&from)
 move operator More...
 

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 55 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 62 of file threadData.h.

References gum::ThreadData< T_DATA >::data.

62 : data(theData) {}
T_DATA data
the data we wish to store without cacheline parallel problem
Definition: threadData.h:99

◆ ThreadData() [2/4]

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

default constructor

Definition at line 65 of file threadData.h.

References gum::ThreadData< T_DATA >::data.

65 : data(std::move(theData)) {}
T_DATA data
the data we wish to store without cacheline parallel problem
Definition: threadData.h:99

◆ ThreadData() [3/4]

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

copy constructor

Definition at line 68 of file threadData.h.

References gum::ThreadData< T_DATA >::data.

68 : data(from.data) {}
T_DATA data
the data we wish to store without cacheline parallel problem
Definition: threadData.h:99

◆ ThreadData() [4/4]

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

move constructor

Definition at line 71 of file threadData.h.

References gum::ThreadData< T_DATA >::data.

71 : data(std::move(from.data)) {}
T_DATA data
the data we wish to store without cacheline parallel problem
Definition: threadData.h:99

◆ ~ThreadData()

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

destructor

Definition at line 74 of file threadData.h.

74 {}

Member Function Documentation

◆ 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 85 of file threadData.h.

References gum::ThreadData< T_DATA >::data.

85  {
86  if (this != &from) data = from.data;
87  return *this;
88  }
T_DATA data
the data we wish to store without cacheline parallel problem
Definition: threadData.h:99

◆ 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 91 of file threadData.h.

References gum::ThreadData< T_DATA >::data.

91  {
92  data = std::move(from.data);
93  return *this;
94  }
T_DATA data
the data we wish to store without cacheline parallel problem
Definition: threadData.h:99

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 99 of file threadData.h.

Referenced by gum::ThreadData< T_DATA >::operator=(), and gum::ThreadData< T_DATA >::ThreadData().


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