#include <common.h>
Inheritance diagram for rpa::range_jump< It >:
Public Types | |
typedef range_lambda< It > | rl_base |
Public Member Functions | |
range_jump (const It &aBeg, const It &aEnd, size_t aJump=JUMP_DEFAULT) | |
Can set a number of threads to use, less than the available threads. | |
void | calc_wdth (thread_tree_core &aThrTree) |
slice | chop (void) |
template<class Rng2> | |
tuple2< slice, typename Rng2::slice > | chop (Rng2 &aSq2) |
Private Attributes | |
size_t | _jump |
It is in fact a number of threads. | |
Classes | |
class | range_out |
In the general case, we keep the original order. More... | |
struct | range_out< It2, std::output_iterator_tag > |
class | slice |
typedef range_lambda< It > rpa::range_jump< It >::rl_base |
This does not need volatile iterators, because the input range is chopped by the main thread.
rpa::range_jump< It >::range_jump | ( | const It & | aBeg, | |
const It & | aEnd, | |||
size_t | aJump = JUMP_DEFAULT | |||
) | [inline] |
Can set a number of threads to use, less than the available threads.
void rpa::range_jump< It >::calc_wdth | ( | thread_tree_core & | aThrTree | ) | [inline] |
We have no idea of the number of elements, and therefore cannot change any run-time parameter, if any.
We keep this number of threads, only if it is less or equal than an upper limit.
tuple2< slice, typename Rng2::slice > rpa::range_jump< It >::chop | ( | Rng2 & | aSq2 | ) | [inline] |
The second sequence must be a range_jump::range_out. The input iterator jumps 'NbThreads' elements at each incrementation. 'chop()' is called once per sub-thread. If the binary 'chop' is used, the unary 'chop' is never directly called.
We give to the 'slave' sequence the threads number, which is also the number of elements it has to increment, to get the next element to process by the same thread. We will reach the end of the sequence if the number of elements is smaller or equal to the sub-threads number. NOTE: If this is the case, we probably started to many sub-threads !
This post-incrementation is here to allow the compiler to eliminate the redundant comparison '_RngBeg == _RngEnd', done in 'iterator_jump_lead constructor.
TODO: This should be replaced by a real 'empty' slice, because we must have several default constructor which should normally be private.
slice rpa::range_jump< It >::chop | ( | void | ) | [inline] |
It is impossible to force a number of elements to 'chop'. This method is called once per sub-thread, but always by the main thread. At each call, we increment by one the iterator used as beginning of each new 'slice'. Therefore, the next call will actually create a new interlaced slice for the next slice. If the sequence is already empty, it returns an empty slice which signals the range's end.
We will reach the end of the sequence if the number of elements is smaller or equal to the number of sub-threads. NOTE: If this is the case, we probably started to many sub-threads !
This post-incrementation is here to allow the compiler to eliminate the redundant comparison '_RngBeg == _RngEnd', done in 'iterator_jump_lead constructor.
size_t rpa::range_jump< It >::_jump [private] |
It is in fact a number of threads.