public final class PlexInt
Fair multiplexes its input integer stream array into one output stream.
Input Channels | ||
---|---|---|
in[] | int | The input streams. |
Output Channels | ||
out | int | The multiplexed output stream. |
import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public final class PlexIntExample { public static void main (String[] argv) { final One2OneChannelInt[] a = ChannelInt.createOne2One (3); final One2OneChannelInt b = ChannelInt.createOne2One (); new Parallel ( new CSProcess[] { new NumbersInt (a[0].out ()), new FibonacciInt (a[1].out ()), new SquaresInt (a[2].out ()), new PlexInt (ChannelInt.getInputArray (a), b.out ()), new PrinterInt (b.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 Plex.
public void run () { Alternative alt = new Alternative (in); // in is the input channel array while (true) { out.write (in[alt.fairSelect ()].in ().read ()); // out is the output channel } }
Constructor and description |
---|
PlexInt
(AltingChannelInputInt[] in, ChannelOutputInt out) Construct a new PlexInt process with input channels in and output channel out. |
Construct a new PlexInt process with input channels in and output channel out. The ordering of the input channels makes no difference to the behaviour of this process.
in
- the input channelsout
- 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