Package org.jcsp.plugNplay
Class ProcessWrite
- java.lang.Object
-
- org.jcsp.plugNplay.ProcessWrite
-
- All Implemented Interfaces:
CSProcess
public class ProcessWrite extends java.lang.Object implements CSProcess
Writes one Object to its output channel.Process Diagram
Description
ProcessWrite is a process that performs a single write to its out channel and then terminates. The Object 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).ProcessWrite 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 java.lang.Object The out Channel can accept data of any Class. Example
ProcessWrite 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:ChannelOutput out0, out1; . . . ProcessWrite write0 = new ProcessWrite (out0); ProcessWrite write1 = new ProcessWrite (out1); CSProcess parWrite01 = new Parallel (new CSProcess[] {out0, out1});
The above is best done once, before any looping over the parallel write 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 ();
The last line above terminates when, and only when, both writes have completed -- the events may occur in any order.- Author:
- P.H. Welch and P.D. Austin
- See Also:
Parallel
,ProcessRead
,ProcessReadInt
,ProcessWriteInt
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.Object
value
The Object to be written to the channel
-
Constructor Summary
Constructors Constructor Description ProcessWrite(ChannelOutput out)
Construct a new ProcessWrite.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
run()
The main body of this process.
-
-
-
Constructor Detail
-
ProcessWrite
public ProcessWrite(ChannelOutput out)
Construct a new ProcessWrite.- Parameters:
out
- the channel to which to write
-
-