rpa::pipebase< Container, CondVar > Class Template Reference

#include <pipeline.h>

Inheritance diagram for rpa::pipebase< Container, CondVar >:

rpa::pipe_container< Container > rpa::pipe_arc_base< Container, CondVar > rpa::pipe_circular< Container, CondVar > rpa::pipe_arc_aux< Container, CondVar, insertInvalidatesIterators > rpa::pipe_arc_aux< Container, CondVar, rpa::insert_invalidates_iterators< Container >::value > rpa::pipe_arc_aux< Container, CondVar, true > rpa::pipe_archiver< Container, CondVar > List of all members.

Public Types

typedef CondVar::mutex_type mutex_type
typedef container_traits<
Container >::iterator 
iterator

Public Member Functions

void check (void) const
template<class ThreadBase>
shutter_thread< ThreadBase > make_shutter (ThreadBase *ptrThr)
 Helper function for creating a shutter_thread out of any thread.
 pipebase (mutex_type *mtxPtr)
 pipebase (mutex_type *mtxPtr, size_t maxNb)
template<class Iter>
 pipebase (mutex_type *mtxPtr, Iter begIter, Iter endIter, bool shutFlag)
 pipebase (mutex_type *mtxPtr, const Container &aCont, bool shutFlag)
void notify_reading_threads (size_t nbInsertedElements)
void shut (void)
bool is_shut (void) const
 If set, waiting threads get the last elements and no longer wait.
 ~pipebase ()

Static Public Member Functions

template<class DrvPip>
static bool wait_data (DrvPip *drvThis)
 Waits for data to read or if the pipe is shut.

Public Attributes

size_t _nbThrWaitToRead
GccNoFriend(protected) iterator _it_rd
iterator _it_beg
iterator _it_end

Protected Attributes

CondVar _condNotEmptyOrShut

Private Types

typedef pipe_container< Container > pip_cont_t

Private Member Functions

void init (mutex_type *mtxPtr, bool shutFlag=false)
 Simple init called by all constructors.

Classes

class  shutter_thread
 This class behaves like a thread proxy. Its use is optional. More...

Detailed Description

template<class Container, class CondVar>
class rpa::pipebase< Container, CondVar >

This is not based on a real pipeline buffer (A pipeline list), but on a plain container (or array) which is 'folded' to make it look like a list.


Member Typedef Documentation

template<class Container, class CondVar>
typedef container_traits< Container >::iterator rpa::pipebase< Container, CondVar >::iterator

Reimplemented from rpa::pipe_container< Container >.

Reimplemented in rpa::pipe_circular< Container, CondVar >, rpa::pipe_archiver< Container, CondVar >, rpa::pipe_arc_base< Container, CondVar >, rpa::pipe_arc_aux< Container, CondVar, insertInvalidatesIterators >, rpa::pipe_arc_aux< Container, CondVar, true >, and rpa::pipe_arc_aux< Container, CondVar, rpa::insert_invalidates_iterators< Container >::value >.

template<class Container, class CondVar>
typedef CondVar::mutex_type rpa::pipebase< Container, CondVar >::mutex_type

Reimplemented in rpa::pipe_circular< Container, CondVar >, rpa::pipe_archiver< Container, CondVar >, rpa::pipe_arc_base< Container, CondVar >, rpa::pipe_arc_aux< Container, CondVar, insertInvalidatesIterators >, rpa::pipe_arc_aux< Container, CondVar, true >, and rpa::pipe_arc_aux< Container, CondVar, rpa::insert_invalidates_iterators< Container >::value >.

template<class Container, class CondVar>
typedef pipe_container< Container > rpa::pipebase< Container, CondVar >::pip_cont_t [private]


Constructor & Destructor Documentation

template<class Container, class CondVar>
rpa::pipebase< Container, CondVar >::pipebase ( mutex_type mtxPtr  )  [inline]

The container is set to the proper size. If this is a plain array, we do nothing. We could do a lazy-resizing, only when it is necessary, but there is no point to wait : If a given size is necessary, why not resizing now ? More: By setting the right size immediately, we ensure that the iterators are always valid. On the other hand, the real shame of it is that we must always pay the price of a full allocation even for a couple of data. (This is also true for output buffers obuf_iterator). To compensate this, a buffer can be reused, once allocated. This default constructor can be used only for unlimited pipes.

template<class Container, class CondVar>
rpa::pipebase< Container, CondVar >::pipebase ( mutex_type mtxPtr,
size_t  maxNb 
) [inline]

template<class Container, class CondVar>
template<class Iter>
rpa::pipebase< Container, CondVar >::pipebase ( mutex_type mtxPtr,
Iter  begIter,
Iter  endIter,
bool  shutFlag 
) [inline]

template<class Container, class CondVar>
rpa::pipebase< Container, CondVar >::pipebase ( mutex_type mtxPtr,
const Container &  aCont,
bool  shutFlag 
) [inline]

template<class Container, class CondVar>
rpa::pipebase< Container, CondVar >::~pipebase (  )  [inline]

The destructor waits until all writers have left, and the readers have read everything. QUESTION: HOW DO WE WAIT ? HOW IS IT DONE ?


Member Function Documentation

template<class Container, class CondVar>
void rpa::pipebase< Container, CondVar >::check ( void   )  const [inline]

This checks that the iterator of the next element to read, is between the beginning and the end of the underlying container. The distance are signed integers to check whether they are negative.

Reimplemented in rpa::pipe_circular< Container, CondVar >.

template<class Container, class CondVar>
void rpa::pipebase< Container, CondVar >::init ( mutex_type mtxPtr,
bool  shutFlag = false 
) [inline, private]

Simple init called by all constructors.

template<class Container, class CondVar>
bool rpa::pipebase< Container, CondVar >::is_shut ( void   )  const [inline]

If set, waiting threads get the last elements and no longer wait.

template<class Container, class CondVar>
template<class ThreadBase>
shutter_thread< ThreadBase > rpa::pipebase< Container, CondVar >::make_shutter ( ThreadBase *  ptrThr  )  [inline]

Helper function for creating a shutter_thread out of any thread.

template<class Container, class CondVar>
void rpa::pipebase< Container, CondVar >::notify_reading_threads ( size_t  nbInsertedElements  )  [inline]

When 'append' inserts many elements, it must notify reading threads:

template<class Container, class CondVar>
void rpa::pipebase< Container, CondVar >::shut ( void   )  [inline]

When this flag is set, a reader thread will not wait if beg==end. Can be called even if there are some more elements to process. They will be processed anyway.

Notifies all threads waiting for values, or for the pipe to be shut.

template<class Container, class CondVar>
template<class DrvPip>
static bool rpa::pipebase< Container, CondVar >::wait_data ( DrvPip *  drvThis  )  [inline, static]

Waits for data to read or if the pipe is shut.

Does not need virtuals for data_ready. The mutex must be locked. It might be worth using an object for the counters of waiting threads, which would be decremented even if an exception were thrown by wait().


Member Data Documentation

template<class Container, class CondVar>
CondVar rpa::pipebase< Container, CondVar >::_condNotEmptyOrShut [protected]

This avoids to make a condition broadcast: Signal is enough. It would be possible to have to kind of conditions as long as they are based on the same mutex.

template<class Container, class CondVar>
iterator rpa::pipebase< Container, CondVar >::_it_beg

template<class Container, class CondVar>
iterator rpa::pipebase< Container, CondVar >::_it_end

template<class Container, class CondVar>
GccNoFriend (protected) iterator rpa::pipebase< Container, CondVar >::_it_rd

template<class Container, class CondVar>
size_t rpa::pipebase< Container, CondVar >::_nbThrWaitToRead

This is used for counting the threads waiting for data or shut. Used for debugging but also for notifying that the pipe is shut.


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