|
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.Object org.jcsp.plugNplay.ints.PlexInt
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 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 Summary | |
---|---|
PlexInt(AltingChannelInputInt[] in,
ChannelOutputInt out)
Construct a new PlexInt process with input channels in and output channel 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 PlexInt(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 |