12 #if defined(_WIN32) && _MSC_VER < 1400
13 #define DtVRL_TBB_UNSUPPORTED 1
15 #define DtVRL_TBB_ARENA_UNSUPPORTED 1
21 #ifndef DtVRL_TBB_UNSUPPORTED
23 #include <tbb/task_arena.h>
25 #pragma message("Warning, DtParallelExecutionContainer parallel execution not supported on VC7 or earlier due to missing TBB dependency.")
69 template <
class Texec>
82 template <
typename T_ReturnValue>
94 #ifndef DtVRL_TBB_UNSUPPORTED
95 void operator()(
const tbb::blocked_range<size_t>& r )
const
98 for(
size_t i=r.begin(); i!=r.end(); ++i )
181 template<
class Texec>
192 template<
class Texec>
197 executeMethodParallel(theMethodPtr);
201 executeMethodSerial(theMethodPtr);
205 template<
class Texec>
210 executeMethodParallel(theMethodPtr);
214 executeMethodSerial(theMethodPtr);
219 template<
class Texec>
222 #ifndef DtVRL_TBB_UNSUPPORTED
223 size_t size = myExecVec.size();
224 tbb::blocked_range<size_t> range(0, size);
226 #ifndef DtVRL_TBB_ARENA_UNSUPPORTED
227 tbb::task_arena limited_arena(myNumThreads);
229 limited_arena.execute([&] { tbb::parallel_for(range, execST); });
233 tbb::parallel_for(range, execST);
237 executeMethodSerial(theMethodPtr);
242 template<
class Texec>
245 #ifndef DtVRL_TBB_UNSUPPORTED
246 size_t size = myExecVec.size();
247 tbb::blocked_range<size_t> range(0, size);
249 tbb::task_arena limited_arena(myNumThreads);
251 limited_arena.execute([&] { tbb::parallel_for(range, execST); });
254 executeMethodSerial(theMethodPtr);
259 template<
class Texec>
264 ((**item).*theMethodPtr)();
269 template<
class Texec>
274 ((**item).*theMethodPtr)();
void operator()(const tbb::blocked_range< size_t > &r) const
Called by TBB to execute a method on a block of objects.
Definition: parallelExecutionContainer.h:96
void DtLeaveParallelExecutionSection()
End publishing in parallel.
virtual void endParallel()
executed after leaving a parallel section
Definition: parallelExecutionContainer.h:167
void DtEnterParallelExecutionSection()
Begin publishing in parallel.
virtual bool isParallel() const
Definition: parallelExecutionContainer.h:148
~DtScopedParallelExecutionLock()
Destructor, which will unlock if locked.
Definition: parallelExecutionContainer.h:55
Contains the DtExecutionContainer class declarations.
virtual bool empty()
Returns true if the container is empty.
Definition: parallelExecutionContainer.h:128
T_ReturnValue(Texec::* myMethodPtr)()
Member method to call in parallel.
Definition: parallelExecutionContainer.h:90
ExecutableItem(const PecContainerType &theCV, T_ReturnValue(Texec::*theMethodPtr)())
ctor with vector of objects and method to call
Definition: parallelExecutionContainer.h:105
bool useParallel
true if using parallel execution, false for serial
Definition: parallelExecutionContainer.h:174
#define DT_DLL_VL
Definition: vlMachineTypes.h:108
const PecContainerType & myCV
Publishers worked upon.
Definition: parallelExecutionContainer.h:87
virtual void executeMethodParallel(void(Texec::*theMethodPtr)())
Execute method on all contained objects in parallel using multiple threads.
Definition: parallelExecutionContainer.h:220
void DtUnlockParallelExecutionAccess()
Unlock a resource only if parallel section is active.
virtual unsigned int count()
Returns the number of items in the container.
Definition: parallelExecutionContainer.h:131
virtual void deleteAndClear()
Delete all referenced objects and then clear the list.
Definition: parallelExecutionContainer.h:182
std::vector< Texec * > PecContainerType
Definition: parallelExecutionContainer.h:74
virtual PecIteratorType begin()
Iterators over the collection.
Definition: parallelExecutionContainer.h:137
bool DtEnableParallelExecutionAccess(bool enable)
Enable locking a resource only if parallel section is active (default).
DtScopedParallelExecutionLock()
Constructs a DtScopedParallelExecutionLock and locks it.
Definition: parallelExecutionContainer.h:52
DtParallelExecutionContainer(bool parallel=true)
Default to parallel execution.
Definition: parallelExecutionContainer.h:115
Convenience class for scoped locking.
Definition: parallelExecutionContainer.h:49
virtual void clear()
Clear the list.
Definition: parallelExecutionContainer.h:125
PecContainerType::iterator PecIteratorType
Definition: parallelExecutionContainer.h:75
virtual PecIteratorType end()
Definition: parallelExecutionContainer.h:138
virtual int maxNumberThreads() const
Definition: parallelExecutionContainer.h:152
int myNumThreads
default is -1 for maximum concurrency
Definition: parallelExecutionContainer.h:177
PecContainerType myExecVec
Contains pointers to published entities.
Definition: parallelExecutionContainer.h:170
virtual void add(Texec *item)
Add a reference to the list.
Definition: parallelExecutionContainer.h:119
virtual void executeMethod(void(Texec::*theMethodPtr)())
worker methods
Definition: parallelExecutionContainer.h:193
void DtLockParallelExecutionAccess()
Lock a resource only if parallel section is active.
virtual void beginParallel()
executed before entering a parallel section
Definition: parallelExecutionContainer.h:164
This class is used by TBB to manage the work units to perform.
Definition: parallelExecutionContainer.h:83
DtExecutionContainer is only the definition of a container which executes methods on all contained ob...
Definition: executionContainer.h:19
virtual void setParallel(bool parallel)
The 'parallel' property determines if the methods are executed in parallel or serial.
Definition: parallelExecutionContainer.h:147
DtParallelExecutionContainer is implementation of DtExecutionContainer which executes methods on all ...
Definition: parallelExecutionContainer.h:70
virtual ~DtParallelExecutionContainer()
Definition: parallelExecutionContainer.h:116
virtual void executeMethodSerial(void(Texec::*theMethodPtr)())
For test and debug, a convenience to execute methods serially.
Definition: parallelExecutionContainer.h:260
virtual void setMaxNumberThreads(int numThreads)
Set maximum number of threads created during executeMothod calls. Default is -1, which uses as many t...
Definition: parallelExecutionContainer.h:151
This file provides protocol independence for DtEntityPublisher.