Package org.jcsp.plugNplay.ints
Class ProcessWriteInt
java.lang.Object
org.jcsp.plugNplay.ints.ProcessWriteInt
- All Implemented Interfaces:
CSProcess
Writes one int to its output channel.
Process Diagram
Description
ProcessWriteInt is a process that performs a single write to its out channel and then terminates. The int that is written must first be placed in the public value field of this process (which is safe to set before and in between process runs).ProcessWriteInt declaration, construction and use should normally be localised within a single method -- so we feel no embarassment about its public field. Its only (envisaged) purpose is as described in the example below.
Channel Protocols
Output Channels | ||
---|---|---|
out | int | All channels in this package carry integers. |
Example
ProcessWriteInt is designed to simplify writing in parallel to channels. Make as many instances as there are channels, binding each instance to a different channel, together with aParallel
object in which to run them:
ChannelOutputInt out0, out1; . . . ProcessWriteInt write0 = new ProcessWriteInt (out0); ProcessWriteInt write1 = new ProcessWriteInt (out1); CSProcess parWrite01 = new Parallel (new CSProcess[] {out0, out1});The above is best done once, before any looping over the parallel read commences. A parallel write can now be performed at any time (and any number of times) by executing:
write0.value = ...; // whatever we want sent down out0 write1.value = ...; // whatever we want sent down out1 parWrite01.run ();This terminates when, and only when, both writes have completed -- the events may occur in any order.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ChannelOutputInt
The channel to which to writeint
The int to be written to the channel -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
value
public int valueThe int to be written to the channel -
out
The channel to which to write
-
-
Constructor Details
-
ProcessWriteInt
Construct a new ProcessWriteInt.- Parameters:
out
- the channel to which to write
-
-
Method Details