Package org.jcsp.lang
Class PriParallel
java.lang.Object
org.jcsp.lang.Parallel
org.jcsp.lang.PriParallel
- All Implemented Interfaces:
CSProcess
This is an extension of the
Parallel
class that prioritises
the processes given to its control.
Description
PriParallel is an extension of theParallel
class that prioritises
the processes given to its control.
The ordering of the processes in
the array passed to the constructor (or added/inserted later) is significant,
with earlier processes having higher priority. The last process in the
array inherits the priority of the constructing process. That priority may
be set explicitly by setPriority
.
Implementation Note: these priorities are currently implemented using the underlying threads priority mechanism. If there are more priorities required than the maximum allowed for the threadgroup of the spawning process, the higher requested priorities will be truncated to that maximum. Also, the semantics of priority will be that implemented by the JVM being used.
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new PriParallel object initially without any processes.PriParallel
(CSProcess[] processes) Construct a new PriParallel object with the processes specified. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
This returns the current priority of this process.void
insertProcessAt
(CSProcess process, int index) Insert another process to the pri-parallel object at the specifed index.static void
setPriority
(int newPriority) This changes the priority of this process.Methods inherited from class org.jcsp.lang.Parallel
addProcess, addProcess, addToAllParThreads, destroy, finalize, getNumberProcesses, releaseAllThreads, removeAllProcesses, removeFromAllParThreads, removeProcess, resetDestroy, run, setUncaughtErrorDisplay, setUncaughtExceptionDisplay, uncaughtException
-
Constructor Details
-
PriParallel
public PriParallel()Construct a new PriParallel object initially without any processes. Processes may be added later using the inherited addProcess methods. The order of their adding is significant, with ealier processes having higher priority. -
PriParallel
Construct a new PriParallel object with the processes specified. The ordering of the processes in the array is significant, with ealier processes having higher priority. The last process in the array inherits the priority of the constructing process.- Parameters:
processes
- The processes to be executed in parallel
-
-
Method Details
-
insertProcessAt
Insert another process to the pri-parallel object at the specifed index. The point of insertion is significant because the ordering of process components determines the priorities. The extended network will be executed the next time run() is invoked.- Overrides:
insertProcessAt
in classParallel
- Parameters:
process
- the process to be insertedindex
- the index at which to insert the process
-
getPriority
public static int getPriority()This returns the current priority of this process.- Returns:
- the current priority of this process.
-
setPriority
public static void setPriority(int newPriority) This changes the priority of this process. Note that JCSP only provides this method for changing the priority of the invoking process. Changing the process of another process is not considered wise.Implementation Note: these priorities are currently implemented using the underlying threads priority mechanism - hence run time exceptions corresponding to the
Thread
.getPriority() may be thrown.
-