Package org.jcsp.lang

Class 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.

    • 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.