Inheritance diagram for csp::common::Merger< DATA_TYPE >:
The Merger process waits for input on one of its channels, and then sends it out on its output channel. 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 latter, with a FIFO buffer of size 1, 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 Merger<int>(c.reader(),d.reader(),e.writer())) (new OtherWidget(e.reader())) );
FIFOBuffer<int>::Factory factory(1); BufferedAny2OneChannel<int> c(factory); Run(InParallel (new Widget(c.writer())) (new Widget(c.writer())) (new OtherWidget(c.reader())) );
Public Member Functions | |
template<typename ITERATOR> | |
Merger (ITERATOR _begin, ITERATOR _end, const Chanout< DATA_TYPE > &_out) | |
Constructs the process using input channels defined by an iterator range. | |
Merger (const std::vector< AltChanin< DATA_TYPE > > &_in, const Chanout< DATA_TYPE > &_out) | |
Constructs the process using the given std::vector of input channels. | |
Merger (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. |
csp::common::Merger< DATA_TYPE >::Merger | ( | 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).
_in0 | One of the input channels | |
_in1 | The other input channel | |
_out | The output channel |
csp::common::Merger< DATA_TYPE >::Merger | ( | 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.
_in | The vector of input channels | |
_out | The output channel |
csp::common::Merger< DATA_TYPE >::Merger | ( | 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
_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 |
void csp::common::Merger< 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.