1#ifndef DUNE_FEM_THREADSAFEVALUES_HH
2#define DUNE_FEM_THREADSAFEVALUES_HH
6#include <dune/fem/misc/mpimanager.hh>
19#ifdef USE_SMP_PARALLEL
20 const typename MPIManager::ThreadPoolType& threadPool_;
21 std::vector< T > value_;
27#ifdef USE_SMP_PARALLEL
28 return threadPool_.thread();
38 template<
class ...Args >
40#ifdef USE_SMP_PARALLEL
41 : threadPool_( MPIManager::threadPool() ),
42 value_( threadPool_.maxThreads(),
ValueType( std::forward< Args >( args )... ) )
44 : value_( std::forward< Args >( args )... )
51#ifdef USE_SMP_PARALLEL
52 threadPool_( MPIManager::threadPool() ),
55#ifdef USE_SMP_PARALLEL
56 threadPool_.maxThreads()
63#ifdef USE_SMP_PARALLEL
64 return threadPool_.maxThreads();
80 assert( thread <
size() );
81#ifdef USE_SMP_PARALLEL
82 assert( thread < value_.size() );
85#ifdef USE_SMP_PARALLEL
93 assert( thread <
size() );
94#ifdef USE_SMP_PARALLEL
95 assert( thread < value_.size() );
98#ifdef USE_SMP_PARALLEL
ThreadSafeValue realizes thread safety for a given variable by creating an instance of this variable ...
Definition: threadsafevalue.hh:18
size_t size() const
return number of threads
Definition: threadsafevalue.hh:62
ValueType & operator*()
return reference to thread private value
Definition: threadsafevalue.hh:71
ValueType & operator[](const unsigned int thread)
return reference to private value for given thread number
Definition: threadsafevalue.hh:79
T ValueType
type of value to be thread safe
Definition: threadsafevalue.hh:35
ThreadSafeValue()
default constructor
Definition: threadsafevalue.hh:49
ThreadSafeValue(Args &&...args)
constructor initializing values for all threads given a init value
Definition: threadsafevalue.hh:39
Dune namespace.
Definition: alignedallocator.hh:13