#include <transform.h>
Inheritance diagram for rpa::transform_loop_thr< Args, Task, Thread >:
Public Types | |
typedef tuple2< typename Args::range_in_t::slice, typename Args::range_out_t::slice > | PairT |
typedef Args::result_type | result_type |
Public Member Functions | |
const result_type & | reduction (Args *ptrArgs) |
Private Types | |
typedef thread_stack< Task, Thread > | ThrStack |
typedef tuple2< typename Args::range_in_t::slice, typename Args::range_out_t::slice > rpa::transform_loop_thr< Args, Task, Thread >::PairT |
typedef Args::result_type rpa::transform_loop_thr< Args, Task, Thread >::result_type |
Reimplemented from rpa::thread_stack< Task, Thread >.
typedef thread_stack< Task, Thread > rpa::transform_loop_thr< Args, Task, Thread >::ThrStack [private] |
const result_type& rpa::transform_loop_thr< Args, Task, Thread >::reduction | ( | Args * | ptrArgs | ) | [inline] |
Called only after all sub-threads are started. Waits with a join, each sub-thread, one after the other, in the order they were started. Do some cleanup as well, in the order these sub-threads were started, potentially for flushing into the output iterator.
We iterate in the object 'ThrStack', in the order with which the threads were started. For this algorithm, the intermediary results are unneeded. But we must wait for each thread before unstacking.
The method operator()(void) makes a join for the thread, and return the result of the functor - which may be different from our return type. Therefore, there is a conversion operator, whose role is, typically, to flush buffers of the output iterator. The role of 'reduce' is to do nothing for plain output iterators. But it flushes obuf_iterator. Returns a value (Not needed here). NOTE: We do not store the result of 'Forkifyoperator()' in a temporary variable because it breaks some run-time checks and asserts.
We have to return the content of 'Args' because the datatype of the sequence output iterator, is different from the datatype of the slices output iterators, in general.