public final class PlexInt extends Object implements CSProcess
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 class PlexIntExample { public static void main (String[] argv) { final One2OneChannelInt[] a = Channel.one2oneIntArray (3); final One2OneChannelInt b = Channel.one2oneInt (); new Parallel ( new CSProcess[] { new NumbersInt (a[0].out ()), new FibonacciInt (a[1].out ()), new SquaresInt (a[2].out ()), new PlexInt (Channel.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 ()].read ()); // out is the output channel } }
Plex2Int
,
MultiplexInt
Constructor and Description |
---|
PlexInt(AltingChannelInputInt[] in,
ChannelOutputInt out)
Construct a new PlexInt process with input channels
in and output channel out.
|
public PlexInt(AltingChannelInputInt[] in, ChannelOutputInt out)
in
- the input channelsout
- the output channelCopyright © 1996–2016. All rights reserved.