csp::common::ExtMerger< DATA_TYPE > Class Template Reference

Inheritance diagram for csp::common::ExtMerger< DATA_TYPE >:

csp::CSProcess csp::ThreadCSProcess boost::noncopyable List of all members.

Detailed Description

template<typename DATA_TYPE>
class csp::common::ExtMerger< DATA_TYPE >

Merges the data from multiple channels into one, using extended input to prevent buffering.

The Merger process waits for input on one of its channels, and then sends it out on its output channel as part of an extended input (finishing the extended input once the output has completed). The waiting for input is done fairly (using Alternative::fairSelect()) so starvation will not occur.

If you can alter that part of your application, you may want to consider using Any2OneChannel or BufferedAny2OneChannel. The former has exactly the same effect as multiple One2OneChannel joined together with this process. That is, this:

        One2OneChannel<int> c,d,e;
        Run(InParallel
            (new Widget(c.writer()))
            (new Widget(d.writer()))
            (new ExtMerger<int>(c.reader(),d.reader(),e.writer()))
            (new OtherWidget(e.reader()))
        );
Is the same as:
        Any2OneChannel<int> c(factory);     
        Run(InParallel
            (new Widget(c.writer()))
            (new Widget(c.writer()))            
            (new OtherWidget(c.reader()))
        );

DATA_TYPE Requirements

DATA_TYPE must have a default constructor, and must meet the requirements of the channels it is being used with.


Public Member Functions

template<typename ITERATOR>
 ExtMerger (ITERATOR _begin, ITERATOR _end, const Chanout< DATA_TYPE > &_out)
 Constructs the process using input channels defined by an iterator range.
 ExtMerger (const std::vector< AltChanin< DATA_TYPE > > &_in, const Chanout< DATA_TYPE > &_out)
 Constructs the process using the given std::vector of input channels.
 ExtMerger (const AltChanin< DATA_TYPE > &_in0, const AltChanin< DATA_TYPE > &_in1, const Chanout< DATA_TYPE > &_out)
 Constructs the process with two input channels (a constructor for convenience).

Protected Member Functions

void run ()
 You must implement this function to provide the code for your process.


Constructor & Destructor Documentation

template<typename DATA_TYPE>
csp::common::ExtMerger< DATA_TYPE >::ExtMerger ( const AltChanin< DATA_TYPE > &  _in0,
const AltChanin< DATA_TYPE > &  _in1,
const Chanout< DATA_TYPE > &  _out 
) [inline]

Constructs the process with two input channels (a constructor for convenience).

Parameters:
_in0 One of the input channels
_in1 The other input channel
_out The output channel

template<typename DATA_TYPE>
csp::common::ExtMerger< DATA_TYPE >::ExtMerger ( const std::vector< AltChanin< DATA_TYPE > > &  _in,
const Chanout< DATA_TYPE > &  _out 
) [inline]

Constructs the process using the given std::vector of input channels.

To use other collection classes, use the other constructor that takes iterators as parameters.

Parameters:
_in The vector of input channels
_out The output channel

template<typename DATA_TYPE>
template<typename ITERATOR>
csp::common::ExtMerger< DATA_TYPE >::ExtMerger ( ITERATOR  _begin,
ITERATOR  _end,
const Chanout< DATA_TYPE > &  _out 
) [inline]

Constructs the process using input channels defined by an iterator range.

The iterators should be iterators over a collection of AltChanin<DATA_TYPE>. They will be passed to the constructor of std::vector< AltChanin<DATA_TYPE> > so they must meet the requirements for that; all the values from *_begin up to (but not including) *_end will be added to the list of input channels

Parameters:
_begin The iterator of the first channel input-end to add
_end The iterator beyond the last channel input-end to add
_out The output channel


Member Function Documentation

template<typename DATA_TYPE>
void csp::common::ExtMerger< DATA_TYPE >::run (  )  [inline, protected, virtual]

You must implement this function to provide the code for your process.

When the run method finishes, the process will terminate.

You should not let an uncaught exception cause the end of this function. If it derives from std::exception, it will be caught (although this behaviour should not be relied upon) but otherwise undefined behaviour will result.

Implements csp::ThreadCSProcess.


Generated on Mon Aug 20 12:24:29 2007 for C++CSP2 by  doxygen 1.4.7