public final class Plex2Int extends java.lang.Object implements CSProcess
in0 __________ -->--| | out in1 | Plex2Int |-->-- -->--|__________|
Input Channels | ||
---|---|---|
in0, in1 | int | The input streams. |
Output Channels | ||
out | int | The multiplexed output stream. |
import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class Plex2IntExample { public static void main (String[] argv) { final One2OneChannelInt a = Channel.one2oneInt (); final One2OneChannelInt b = Channel.one2oneInt (); final One2OneChannelInt c = Channel.one2oneInt (); 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 ()].read ()); // out is the output channel } }
PlexInt
,
MultiplexInt
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.
|
Modifier and Type | Method and Description |
---|---|
void |
run()
The main body of this process.
|
public Plex2Int(AltingChannelInputInt in0, AltingChannelInputInt in1, ChannelOutputInt out)
in0
- an input channelin1
- an input channelout
- the output channelSubmit a bug or feature to jcsp-team@kent.ac.uk
Version 1.1-rc4 of the JCSP API Specification (Copyright 1997-2008 P.D.Austin and P.H.Welch - All Rights Reserved)
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.