#include <pipeline.h>
Inheritance diagram for rpa::pipe_arc_base< Container, CondVar >:
Public Types | |
typedef pipebase< Container, CondVar > | pipebase_t |
typedef pipebase_t::iterator | iterator |
typedef pipebase_t::value_type | value_type |
typedef pipebase_t::mutex_type | mutex_type |
typedef pipe_itr< value_type, reader > | sync_iter |
Public Member Functions | |
pipe_arc_base (mutex_type *mtxPtr) | |
template<class Iter> | |
pipe_arc_base (mutex_type *mtxPtr, Iter begIter, Iter endIter, bool shutFlag=true) | |
pipe_arc_base (mutex_type *mtxPtr, const Container &aCont, bool shutFlag=true) | |
bool | data_ready (void) const |
Tells whether the pipe is not empty. Called by wait_data. | |
sync_iter | begin (void) |
sync_iter | end (void) |
Protected Member Functions | |
void | push_back_refresh (const value_type &aV) |
template<class IterIn> | |
size_t | append_refresh (IterIn itBeg, IterIn itEnd, size_t szRsrv) |
Updates pointers, notifies threads and returns the inserted elements number. | |
Classes | |
class | reader |
Models how to read from a pipe_archiver. More... |
typedef pipebase_t::iterator rpa::pipe_arc_base< Container, CondVar >::iterator |
Reimplemented from rpa::pipebase< Container, CondVar >.
Reimplemented in rpa::pipe_archiver< 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 >.
typedef pipebase_t::mutex_type rpa::pipe_arc_base< Container, CondVar >::mutex_type |
Reimplemented from rpa::pipebase< Container, CondVar >.
Reimplemented in rpa::pipe_archiver< 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 >.
typedef pipebase< Container, CondVar > rpa::pipe_arc_base< Container, CondVar >::pipebase_t |
typedef pipe_itr< value_type, reader > rpa::pipe_arc_base< Container, CondVar >::sync_iter |
typedef pipebase_t::value_type rpa::pipe_arc_base< Container, CondVar >::value_type |
rpa::pipe_arc_base< Container, CondVar >::pipe_arc_base | ( | 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.
rpa::pipe_arc_base< Container, CondVar >::pipe_arc_base | ( | mutex_type * | mtxPtr, | |
Iter | begIter, | |||
Iter | endIter, | |||
bool | shutFlag = true | |||
) | [inline] |
rpa::pipe_arc_base< Container, CondVar >::pipe_arc_base | ( | mutex_type * | mtxPtr, | |
const Container & | aCont, | |||
bool | shutFlag = true | |||
) | [inline] |
size_t rpa::pipe_arc_base< Container, CondVar >::append_refresh | ( | IterIn | itBeg, | |
IterIn | itEnd, | |||
size_t | szRsrv | |||
) | [inline, protected] |
Updates pointers, notifies threads and returns the inserted elements number.
We must notify AT LEAST the number of elements inserted. Otherwise, some threads could wait, although there would be elements ready to be read. The condition variable must be able to make a broadcast if the number of inserted elements is too big, because there cannot possibly be the same number of threads.
sync_iter rpa::pipe_arc_base< Container, CondVar >::begin | ( | void | ) | [inline] |
These two iterators can be used into algorithm of std. Each value can be read only once.
Reimplemented from rpa::pipe_container< Container >.
bool rpa::pipe_arc_base< Container, CondVar >::data_ready | ( | void | ) | const [inline] |
Tells whether the pipe is not empty. Called by wait_data.
sync_iter rpa::pipe_arc_base< Container, CondVar >::end | ( | void | ) | [inline] |
Reimplemented from rpa::pipe_container< Container >.
void rpa::pipe_arc_base< Container, CondVar >::push_back_refresh | ( | const value_type & | aV | ) | [inline, protected] |
The mutex must be already locked. For some containers, all the iterators may be invalidated for each insertion. These updates, which are specific to the container, are done in the 'push_back' method which calls this one. Here, we do only the updates which must be logically done for any type of container.
We notify only one thread because there is only one element to read.