rpa::range_step< It, Mutex > Class Template Reference

#include <common.h>

Inheritance diagram for rpa::range_step< It, Mutex >:

rpa::range_step_aux< It > rpa::range_step_base< It > List of all members.

Public Types

typedef guard< Mutex > guard_t
typedef range_step_aux< It > rsa_base
typedef rsa_base::slice slice

Public Member Functions

 range_step (It aBeg, It aEnd, size_t aStep, Mutex &aMtx, chunk_t aMinChkSz=chunk_t())
slice chop (void)
 The huge difference with the base 'chop' is the lock.
size_t chop_again (slice &refSlice)
slice chop_init_lock_cond (bool mustLock)
template<class Rng2>
tuple2< slice, typename Rng2::slice > chop_init_lock_cond (Rng2 &aSq2, bool mustLock)
template<class Rng2>
size_t chop_again (tuple2< slice, typename Rng2::slice > &aPairRef, Rng2 &aSq2)

Private Member Functions

 range_step ()
range_stepoperator= (const range_step &)

Private Attributes

Mutex * _ptrMtx

Detailed Description

template<class It, class Mutex>
class rpa::range_step< It, Mutex >

This is a range for dynamic scheduling, with a fixed number of elements (the step) taken for calculation by each sub-thread when it is idle. The mutex protects the iterator, because several threads read it.


Member Typedef Documentation

template<class It, class Mutex>
typedef guard< Mutex > rpa::range_step< It, Mutex >::guard_t

Used to block others sub-threads, when a new 'slice', i.e. a processing unit, is chopped from the input range, by a sub-thread which just started.

template<class It, class Mutex>
typedef range_step_aux< It > rpa::range_step< It, Mutex >::rsa_base

template<class It, class Mutex>
typedef rsa_base::slice rpa::range_step< It, Mutex >::slice

Reimplemented from rpa::range_step_aux< It >.


Constructor & Destructor Documentation

template<class It, class Mutex>
rpa::range_step< It, Mutex >::range_step (  )  [private]

template<class It, class Mutex>
rpa::range_step< It, Mutex >::range_step ( It  aBeg,
It  aEnd,
size_t  aStep,
Mutex &  aMtx,
chunk_t  aMinChkSz = chunk_t() 
) [inline]

This takes as input args, the begin and the end of an input range, a mutex for protecting the critical sections, and a minimal interval size, below which it is better to run in single-threaded mode.


Member Function Documentation

template<class It, class Mutex>
slice rpa::range_step< It, Mutex >::chop ( void   )  [inline]

The huge difference with the base 'chop' is the lock.

Reimplemented from rpa::range_step_aux< It >.

template<class It, class Mutex>
template<class Rng2>
size_t rpa::range_step< It, Mutex >::chop_again ( tuple2< slice, typename Rng2::slice > &  aPairRef,
Rng2 &  aSq2 
) [inline]

Flushes the output buffer, then gets a new iterator pair. The range_step mutex is used to protect the flush, AND to 'chop' a new pair of slices.

Protects the slice assignation AND the chop.

Assigns instead of returning the new pair, because we want to benefit from the mutex.

template<class It, class Mutex>
size_t rpa::range_step< It, Mutex >::chop_again ( slice refSlice  )  [inline]

It is cheaper to reuse the same slice, and avoiding the ctor/dtor is useful because they may make other complicated things which are good to avoid.

Protects the slice assignation AND the chop.

Assigns instead of returning the new slice, because we want to benefit from the mutex protection. The possibly derived part of the slice stays untouched.

template<class It, class Mutex>
template<class Rng2>
tuple2< slice, typename Rng2::slice > rpa::range_step< It, Mutex >::chop_init_lock_cond ( Rng2 &  aSq2,
bool  mustLock 
) [inline]

When looping on the sub-threads creation, it is unnecessary to lock the input sequence at first call, because no other thread is running.

template<class It, class Mutex>
slice rpa::range_step< It, Mutex >::chop_init_lock_cond ( bool  mustLock  )  [inline]

When looping on the sub-threads creation, it is unnecessary to lock the input sequence at first call, because no other thread is running.

template<class It, class Mutex>
range_step& rpa::range_step< It, Mutex >::operator= ( const range_step< It, Mutex > &   )  [private]


Member Data Documentation

template<class It, class Mutex>
Mutex* rpa::range_step< It, Mutex >::_ptrMtx [private]


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