|
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.Plex2
public final class Plex2
Fair multiplexes two Object streams into one.
in0 _______ -->--| | out in1 | Plex2 |-->-- -->--|_______|
Input Channels | ||
---|---|---|
in0, in1 | java.lang.Object | The input streams. |
Output Channels | ||
out | java.lang.Object | The multiplexed output stream. |
import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class Plex2Example { public static void main (String[] argv) { final One2OneChannel[] a = Channel.one2oneArray (2); final One2OneChannel[] b = Channel.one2oneArray (2); final One2OneChannel c = Channel.one2one (); new Parallel ( new CSProcess[] { new Fibonacci (a[0].out ()), new Squares (a[1].out ()), new Sign ("Fibonacci ", a[0].in (), b[0].out ()), new Sign (" Squares ", a[1].in (), b[1].out ()), new Plex2 (b[0].in (), b[1].in (), c.out ()), new Printer (c.in (), "", "\n") } ).run (); } }
public void run () { AltingChannelInput[] 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 } }
Plex
,
Multiplex
Constructor Summary | |
---|---|
Plex2(AltingChannelInput in0,
AltingChannelInput in1,
ChannelOutput out)
Construct a new Plex2 process with the input channels in0 and in1 and the 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 Plex2(AltingChannelInput in0, AltingChannelInput in1, ChannelOutput out)
in0
- an input channelin1
- an input channelout
- 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 |