aGrUM  0.16.0
threadData.h
Go to the documentation of this file.
1 
29 #ifndef GUM_THREAD_DATA_H
30 #define GUM_THREAD_DATA_H
31 
32 #include <new>
33 
34 #include <agrum/agrum.h>
35 
36 namespace gum {
37 
53  template < typename T_DATA >
54  // #TODO: replace by alignas(std::hardware_destructive_interference_size)
55  // when pyAgrum will be compiled in C++17
56  struct alignas(128) ThreadData {
57  // ##########################################################################
59  // ##########################################################################
61 
63  ThreadData(const T_DATA& theData) : data(theData) {}
64 
66  ThreadData(T_DATA&& theData) : data(std::move(theData)) {}
67 
69  ThreadData(const ThreadData< T_DATA >& from) : data(from.data) {}
70 
72  ThreadData(ThreadData< T_DATA >&& from) : data(std::move(from.data)) {}
73 
76 
78 
79  // ##########################################################################
81  // ##########################################################################
82 
84 
87  if (this != &from) data = from.data;
88  return *this;
89  }
90 
93  data = std::move(from.data);
94  return *this;
95  }
96 
98 
100  T_DATA data;
101  };
102 
103 } /* namespace gum */
104 
105 #endif /* GUM_THREAD_DATA_H */
ThreadData(const T_DATA &theData)
default constructor
Definition: threadData.h:63
ThreadData(T_DATA &&theData)
default constructor
Definition: threadData.h:66
STL namespace.
A wrapper that enables to store data in a way that prevents false cacheline sharing.
Definition: threadData.h:56
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
ThreadData(const ThreadData< T_DATA > &from)
copy constructor
Definition: threadData.h:69
ThreadData< T_DATA > & operator=(ThreadData< T_DATA > &&from)
move operator
Definition: threadData.h:92
ThreadData< T_DATA > & operator=(const ThreadData< T_DATA > &from)
copy operator
Definition: threadData.h:86
ThreadData(ThreadData< T_DATA > &&from)
move constructor
Definition: threadData.h:72
T_DATA data
the data we wish to store without cacheline parallel problem
Definition: threadData.h:100
~ThreadData()
destructor
Definition: threadData.h:75