rpa::range_jump< It > Class Template Reference

#include <common.h>

Inheritance diagram for rpa::range_jump< It >:

rpa::range_lambda< It > List of all members.

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

Detailed Description

template<class It>
class rpa::range_jump< It >

This is an interleaved scheduling : Each sub-threads, processes one element out of 'NbThreads'. Therefore, there is no dependency between the iterators of each sub-threads, and no mutex is necessary.


Member Typedef Documentation

template<class It>
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.


Constructor & Destructor Documentation

template<class It>
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.


Member Function Documentation

template<class It>
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.

template<class It>
template<class Rng2>
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.

template<class It>
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.


Member Data Documentation

template<class It>
size_t rpa::range_jump< It >::_jump [private]

It is in fact a number of threads.


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