#include <accumulate.h>
Public Types | |
typedef AccumulateVec::RngIn | RngIn |
typedef RngIn::slice::iterator | iterator_t |
typedef RngIn::slice | SliceIn |
typedef AccumulateVec::result_type | result_type |
Public Member Functions | |
coroutine_step (RngIn &aRngIn, bool mustLock, Ftor &aFunc) | |
bool | empty_slice (void) const |
To check whether it is worth to run the functor after its creation. | |
result_type | operator() (void) |
Must be called the same number of times as a sequential algorithm. | |
Public Attributes | |
RngIn & | _seqIn |
Ftor & | _func |
Private Attributes | |
SliceIn | _sliceIn |
This class is put outside the definition of accumulate_vec because of compile problems due to template specialisations inside template specialisation. This functor is executed instead of the original one.
typedef RngIn::slice::iterator rpa::coroutine_step< AccumulateVec, Ftor >::iterator_t |
typedef AccumulateVec::result_type rpa::coroutine_step< AccumulateVec, Ftor >::result_type |
typedef AccumulateVec::RngIn rpa::coroutine_step< AccumulateVec, Ftor >::RngIn |
typedef RngIn::slice rpa::coroutine_step< AccumulateVec, Ftor >::SliceIn |
rpa::coroutine_step< AccumulateVec, Ftor >::coroutine_step | ( | RngIn & | aRngIn, | |
bool | mustLock, | |||
Ftor & | aFunc | |||
) | [inline] |
bool rpa::coroutine_step< AccumulateVec, Ftor >::empty_slice | ( | void | ) | const [inline] |
To check whether it is worth to run the functor after its creation.
result_type rpa::coroutine_step< AccumulateVec, Ftor >::operator() | ( | void | ) | [inline] |
Must be called the same number of times as a sequential algorithm.
Necessary otherwise we would have to return a default value if the slice is empty, which makes no sense in the general case.
This debugging statement is bit dangerous because not thread-safe, but this does not really matters because it is for displaying only.
In general, we do not know this functor's neutral element. For 'int' and 'float', it is zero, but otherwise ... Moreover, we want to have the same number of functor calls, whether the algorithm execution is sequential or parallel, and whatever the number of threads is. So, the 'init value' of this algorithm is the value pointed to by the 'begin' of this sequence.
Is this the end of the sequence ? Using 'chop_again' is faster than 'chop' because it is not necessary to call the ctor/dtor of the slice.
Unsetting this flag will force the addition to be made by small pieces which is extremely profitable for strings, because there are less copies for reallocations. But this problem cannot be generalised at the moment.
Ftor& rpa::coroutine_step< AccumulateVec, Ftor >::_func |
RngIn& rpa::coroutine_step< AccumulateVec, Ftor >::_seqIn |
SliceIn rpa::coroutine_step< AccumulateVec, Ftor >::_sliceIn [private] |