CSP for Java
(JCSP) 1.1-rc4

org.jcsp.lang
Class PriParallel

java.lang.Object
  extended by org.jcsp.lang.Parallel
      extended by org.jcsp.lang.PriParallel
All Implemented Interfaces:
CSProcess

public class PriParallel
extends Parallel

This is an extension of the Parallel class that prioritises the processes given to its control.

Description

PriParallel is an extension of the Parallel 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.

Author:
P.D. Austin

Constructor Summary
PriParallel()
          Construct a new PriParallel object initially without any processes.
PriParallel(CSProcess[] processes)
          Construct a new PriParallel object with the processes specified.
 
Method Summary
static int getPriority()
          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, destroy, finalize, getNumberProcesses, releaseAllThreads, removeAllProcesses, removeProcess, resetDestroy, run, setUncaughtErrorDisplay, setUncaughtExceptionDisplay
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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

public PriParallel(CSProcess[] processes)
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 Detail

insertProcessAt

public void insertProcessAt(CSProcess process,
                            int index)
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 class Parallel
Parameters:
process - the process to be inserted
index - 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.

Throws:
java.lang.IllegalArgumentException - if the priority is not in the range supported by the underlying threads implementation.
java.lang.SecurityException - if the security manager of the underlying threads implementation will not allow this modification.

CSP for Java
(JCSP) 1.1-rc4

Submit a bug or feature to jcsp-team@kent.ac.uk
Version 1.1-rc4 of the JCSP API Specification (Copyright 1997-2008 P.D.Austin and P.H.Welch - All Rights Reserved)
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.