|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jcsp.nxt.lang.Parallel
public class Parallel
This process constructor taks an array of CSProcesses and returns a CSProcess that is the parallel composition of its process arguments.
Shortcut to the Constructor and Method Summaries.
Note: for those familiar with the occam multiprocessing language, the Parallel class gives the semantics of the PAR construct. However, none of the parallel usage checks mandated by occam can be made by the Java compiler, so we need to exercise that care ourselves. For instance, do not try to run the same process instance more than once in parallel and, generally, watch out for accidentally shared objects! Running different instances of the same process in parallel is, of course, allowed.
CSProcesses can be added to a Parallel object either via
the constructor or the addProcess methods.
If a call to addProcess is made while the run method is executing,
the extra process(es) will not be included in the network until the next time
run is invoked.
CSProcesses can be removed from a Parallel object
via the removeProcess or
removeAllProcesses method.
If a call to removeProcess or removeAllProcesses
is made while the run method is executing, the process will
not be removed from the network until the next time run is
invoked.
Non-determinism, of course, needs to be addressed for many applications
and is catered for in JCSP by its Alternative construct
(which corresponds to the CSP external choice operator and occam ALT)
The fact that non-determinism has to be explicitly introduced reduces
the chance of overlooking race-hazards caused by that non-determinism.
| Constructor Summary | |
|---|---|
Parallel()
Construct a new Parallel object initially without any processes. |
|
| Method Summary | |
|---|---|
void |
addProcess(CSProcess process)
Add the process to the Parallel object. |
(package private) static void |
addToAllParThreads(java.lang.Thread newThread)
Adds the thread object to the allParThreads collection. |
static void |
destroy()
Stops all threads created by all Parallel and ProcessManager objects. |
int |
getNumberProcesses()
|
(package private) static void |
removeFromAllParThreads(java.lang.Thread oldThread)
Removes the thread object from the allParThreads collection. |
static void |
resetDestroy()
Cancels a call to destroy allowing the JCSP system to be reused. |
void |
run()
Run the parallel composition of the processes registered with this Parallel object. |
static void |
setUncaughtErrorDisplay(boolean enable)
Enables or disables the display or Errors uncaught by a CSProcess running within a Parallel or under a ProcessManager object. |
static void |
setUncaughtExceptionDisplay(boolean enable)
Enables or disables the display of Exceptions uncaught by a CSProcess running within a Parallel or under a ProcessManager object. |
(package private) static void |
uncaughtException(java.lang.String caller,
java.lang.Throwable t)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Parallel()
| Method Detail |
|---|
static void addToAllParThreads(java.lang.Thread newThread)
throws InterruptedException
allParThreads collection. This should be called by any infrastructure threads when they start.
newThread - the thread to be added to the collection.
InterruptedExceptionstatic void removeFromAllParThreads(java.lang.Thread oldThread)
allParThreads collection.
public static void destroy()
ProcessManager objects. No new threads can be
created until the resetDestroy method gets called.
public static void resetDestroy()
public void addProcess(CSProcess process)
process - the CSProcess to be addedpublic int getNumberProcesses()
public void run()
Implementation note: In its first run, only (numProcesses - 1) Threads are created to run the processes -- the last process is executed in the invoking Thread. Sunsequent runs reuse these Threads (so the overhead of thread creation happens only once).
run in interface CSProcesspublic static void setUncaughtExceptionDisplay(boolean enable)
public static void setUncaughtErrorDisplay(boolean enable)
static void uncaughtException(java.lang.String caller,
java.lang.Throwable t)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||