public final class Multiplex extends java.lang.Object implements CSProcess
de-multiplexed
later.
The protocol on the outgoing multiplexed stream consists of
an Integer, 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[] | java.lang.Object | The input streams. |
Output Channels | ||
out | java.lang.Integer, java.lang.Object | The channel index followed by the multiplexed data. |
import org.jcsp.lang.*; import org.jcsp.plugNplay.*; public class MultiplexExample { public static void main (String[] argv) { final One2OneChannel[] a = Channel.one2oneArray (3); final One2OneChannel b = Channel.one2one (); new Parallel ( new CSProcess[] { new Numbers (a[0].out ()), new Fibonacci (a[1].out ()), new Squares (a[2].out ()), new Multiplex (Channel.getInputArray (a), b.out ()), new CSProcess () { public void run () { String[] key = {"Numbers ", " Fibonacci ", " Squares "}; while (true) { int channel = ((Integer) b.in ().read ()).intValue (); System.out.print (key[channel]); // print channel source int n = ((Integer) b.in ().read ()).intValue (); System.out.println (n); // print multiplexed data } } } } ).run (); } }
Demultiplex
,
Paraplex
,
Deparaplex
,
Plex
Constructor and Description |
---|
Multiplex(AltingChannelInput[] in,
ChannelOutput out)
Construct a new Multiplex process with the input Channel in and the output
Channels out.
|
Modifier and Type | Method and Description |
---|---|
void |
run()
The main body of this process.
|
public Multiplex(AltingChannelInput[] in, ChannelOutput out)
in
- the input channelsout
- 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.