public final class Plex2Int
Fair multiplexes two integer streams into one.
Input Channels | ||
---|---|---|
in0, in1 | int | The input streams. |
Output Channels | ||
out | int | The multiplexed output stream. |
import org.org.jcsp.lang.*; import org.org.jcsp.plugNplay.ints.*; public final class Plex2IntExample { public static void main (String[] argv) { final One2OneChannelInt a = ChannelInt.createOne2One (); final One2OneChannelInt b = ChannelInt.createOne2One (); final One2OneChannelInt c = ChannelInt.createOne2One (); new Parallel ( new CSProcess[] { new FibonacciInt (a.out ()), new SquaresInt (b.out ()), new Plex2Int (a.in (), b.in (), c.out ()), new PrinterInt (c.in (), "--> ", "\n") } ).run (); } }Note: this example does not produce easily understandable output, since the multiplexed stream contains only numbers -- there is no indication of the streams from which they were sourced. To get that indication, we can either use MultiplexInt or sign each int stream to be multiplexed with SignInt and multiplex with Plex2.
public void run () { AltingChannelInputInt[] input = {in0, in1}; // in0 and in1 are the input channels Alternative alt = new Alternative (input); while (true) { out.write (input[alt.fairSelect ()].in ().read ()); // out is the output channel } }
Constructor and description |
---|
Plex2Int
(AltingChannelInputInt in0, AltingChannelInputInt in1, ChannelOutputInt out) Construct a new Plex2Int process with the input channels in0 and in1 and the output channel out. |
Construct a new Plex2Int process with the input channels in0 and in1 and the output channel out. The ordering of the input channels makes no difference to the behaviour of this process.
in0
- an input channelin1
- an input channelout
- the output channelJCSP for Java 1.8 generated 14-10-2016 by Jon Kerridge, Edinburgh Napier University - j dot kerridge at napier dot ac dot uk