rpa::accumulate_loop_t< Args, Task, Thread > Class Template Reference

#include <accumulate.h>

Inheritance diagram for rpa::accumulate_loop_t< Args, Task, Thread >:

rpa::thread_stack< Task, Thread > rpa::accumulate_vec< Args, range_step< ItIn, Mutex >, BinOp, ThrIter >::conditional_accumulate_args List of all members.

Public Types

typedef Args::result_type result_type

Public Member Functions

const result_typereduction (Args *ptrArgs)

Private Types

typedef thread_stack< Task,
Thread > 
ThrStack

Detailed Description

template<class Args, class Task, class Thread>
class rpa::accumulate_loop_t< Args, Task, Thread >

Each template specialization of 'accumulate_vec' contains a class 'loop_t', which is a derived class of 'accumulate_loop_t. 'loop_t' is used to build on the stack of the main thread, the data structures needed by each sub-thread. Therefore, there is no need of dynamic allocation of a container, with one element per sub-thread. These data structures (Among them, the 'forfiky' objects, are linked together with a 'ThrStack' object, which contains the begin and the end of a list of data structures, one per sub-thread.


Member Typedef Documentation

template<class Args, class Task, class Thread>
typedef Args::result_type rpa::accumulate_loop_t< Args, Task, Thread >::result_type

Reimplemented from rpa::thread_stack< Task, Thread >.

template<class Args, class Task, class Thread>
typedef thread_stack< Task, Thread > rpa::accumulate_loop_t< Args, Task, Thread >::ThrStack [private]


Member Function Documentation

template<class Args, class Task, class Thread>
const result_type& rpa::accumulate_loop_t< Args, Task, Thread >::reduction ( Args *  ptrArgs  )  [inline]

This can be called only when all sub-threads were run. That is, the method loop_t::run() is recursive, with one call per sub-thread. When it has reached the end of sub-threads to run, that is, when it is at the top of the stack, it calls 'reduction' which can then access all results of each sub-thread, and which are stored on the stack. There may be some thrashing due to the access of several threads to the stack of the main thread, but :

Waits until the complete end, with many join(). All intermediate results are in the stack.

Loops with iterators given by the object 'ThrStack', which has a list of all running sub-threads. The sub-threads are accessd in the same order as they were started. This increase the chance that when the first one is finished before the others.

This waits, with 'join', until the sub-thread has finished and and stored its result in the main thread stack. If the main thread has to wait a long time at reduction, it may be worth to add more threads.

Reimplemented in rpa::accumulate_vec< Args, range_step< ItIn, Mutex >, BinOp, ThrIter >::conditional_accumulate_args.


The documentation for this class was generated from the following file:
Generated on Tue Sep 25 10:20:32 2007 for rpa by  doxygen 1.4.7