Template Class PerThreadDataHolder

Class Documentation

template<class T>
class PerThreadDataHolder

Creates an instance of the data type T per requesting thread.

Public Functions

PerThreadDataHolder() = default
inline T &get()
inline const T &get() const
inline void run_on_all(const std::function<void(T&)> &f)

Note: you should define your own mutex for the part of the user data T that is read & writen from different threads.

inline void clear()
inline PerThreadDataHolder<T> &operator=(const PerThreadDataHolder<T> &o)

Copy the data, leave mutexes apart.

inline PerThreadDataHolder(const PerThreadDataHolder<T> &o)

Copy the data, leave mutexes apart.

inline PerThreadDataHolder<T> &operator=(PerThreadDataHolder<T> &&o)

Move the data, leave mutexes apart.

inline PerThreadDataHolder(PerThreadDataHolder<T> &&o)

Move the data, leave mutexes apart.