|
CSP for Java (JCSP) 1.1-rc4 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jcsp.plugNplay.ints.MultiplexInt
public final class MultiplexInt
Fair multiplexes its input integer stream array into one output stream (carrying source channel and data pairs).
de-multiplexed
later.
The protocol on the outgoing multiplexed stream consists of
an int, that represents the channel identity of the
multiplexed data, followed by the multiplexed data.
The ordering of the channels in the in array makes no difference to the functionality of this process -- the multiplexing services all channels fairly.
Input Channels | ||
---|---|---|
in[] | int | All channels in this package carry integers. |
Output Channels | ||
out | int, int | An out message is an index followed by the multiplexed data. |
import org.jcsp.lang.*; import org.jcsp.plugNplay.ints.*; public class MultiplexIntExample { 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 MultiplexInt (Channel.getInputArray (a), b.out ()), new CSProcess () { public void run () { String[] key = {"Numbers ", " Fibonacci ", " Squares "}; while (true) { System.out.print (key[b.in ().read ()]); // print channel source System.out.println (b.in ().read ()); // print multiplexed data } } } } ).run (); } }
DemultiplexInt
,
ParaplexInt
,
DeparaplexInt
,
PlexInt
Constructor Summary | |
---|---|
MultiplexInt(AltingChannelInputInt[] in,
ChannelOutputInt out)
Construct a new MultiplexInt process with the input Channel in and the output Channels out. |
Method Summary | |
---|---|
void |
run()
The main body of this process. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MultiplexInt(AltingChannelInputInt[] in, ChannelOutputInt out)
in
- the input channelsout
- the output channelMethod Detail |
---|
public void run()
run
in interface CSProcess
|
CSP for Java (JCSP) 1.1-rc4 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |