|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface CSProcess
This is the JCSP interface for a process - an active component that encapsulates the data structures on which it operates.
In this JCSP binding of the CSP model into Java, a process is an instance of a class implementing this CSProcess interface. Its actions are defined by the run method.
Running processes interact solely via CSP channels, events or carefully synchronised access to shared objects -- not by calling each other's methods. These passive objects form the CSP interface to a process. They are not present in the Java interface and must be configured into each process via public constructors and/or mutators when it is not running (i.e. before and in between runs). It is safe to extract information from the process via accessor methods, but only after (or in between) runs.
For other general information, see the JCSP overview.
import org.jcsp.lang.*;
... other imports
class ProcessExample implements CSProcess {
... private/protected shared synchronisation objects (channels etc.)
... private/protected state information
... public constructors
... public configuration/inspection methods (when not running)
... private/protected support methods (part of a run)
... public run method (the process starts here)
}
The pattern of use for these methods is simple and well-disciplined.
The public constructors and configuration methods must install the shared
synchronisation objects into their private/protected fields.
They may also initialise other private/protected state information.
The public configuration/inspection methods (simple sets and
gets) may be invoked only when this process is not running
and are the responsibility of a single process only -- usually
the process that constructed it. That process is also responsible for
invoking the public run method that kicks this one into life
(usually, via a Parallel or ProcessManager intermediary).
The private support methods are triggered only by the run
method and express the live behaviour of this process.
A process instance may have several lives but these must, of course, be consecutive. Different instances of the same process class may, also of course, be alive concurrently. Reconfiguration of a process via its configuration/inspection methods may only take place between lives. Dynamic reconfiguration of a live process may take place -- but only with the active cooperation of the process (for example, through channel communication).
This is not to say that the semantics of processes connected in parallel are simply the sum of the semantics of each individual process -- just that those semantics should contain no surprises. Value can added just through the nature of the parallel composition itself. For example, connect simple stateless processes into a channel feedback-loop, give them some external wires and we get a component that contains state.
The process design pattern defines some powerful simplifications that bring us that control. Backed up with the theory of CSP, it also addresses and offers solutions to some fundamental issues in concurrency and multi-threading.
In unconstrained OO, threads and objects are orthogonal notions -- sometimes dangerously competitive. Threads have no internal structure and can cross object boundaries in spaghetti-like trails that relate objects together in a way that has little correspondence to the original OO design. A process combines these ideas into a single concept, gives it structure and maintains strong encapsulation by guarding the distribution and use of references with some strict (and checkable) design rules. A process may be wired up in parallel with other processes to form a network -- which is itself a process. So, a process may have sub-processes that have sub-sub-processes ad infinitum. This is the way the world works ...
The simplicity of the process design pattern is that each process can be considered individually as an independant serial program, interacting with external I/O devices (the synchronisation objects -- channels etc.). At the other end of those devices may lie other processes, but that is of no concern to the consideration of this process. All our past skills and intuition about serial programming can safely be applied. The new skills needed to design and use parallel process networks sit alongside those earlier skills and no cross-interference takes place.
,
,
ChannelInputInt,
ChannelOutputInt,
| Method Summary | |
|---|---|
void |
run()
This defines the actions of the process. |
| Method Detail |
|---|
void run()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||