Package edu.rit.pj

Class WorkerConstruct

java.lang.Object
edu.rit.pj.WorkerConstruct
Direct Known Subclasses:
WorkerForLoop, WorkerIteration, WorkerRegion

public abstract class WorkerConstruct extends Object
Class WorkerConstruct is the common base class for all worker constructs that are executed by a WorkerTeam.
Version:
19-Jan-2010
Author:
Alan Kaminsky
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a new worker construct.
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
    Determine the number of worker threads in the current process in the worker team executing this worker construct.
    final int
    Determine the index of the calling thread in the worker team executing this worker construct.
    final int
    Determine the total number of worker threads in all processes in the worker team executing this worker construct.
    final boolean
    Determine if a worker team is executing this worker construct.
    final boolean
    Determine if the calling thread is the master thread in the worker team executing this worker construct.
    Returns the worker region of code within which a worker team is executing this worker construct.
    Returns the worker team that is executing this worker construct.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WorkerConstruct

      public WorkerConstruct()
      Construct a new worker construct.
  • Method Details

    • isExecutingInParallel

      public final boolean isExecutingInParallel()
      Determine if a worker team is executing this worker construct.
      Returns:
      True if a worker team is executing this worker construct, false otherwise.
    • team

      public final WorkerTeam team()
      Returns the worker team that is executing this worker construct.
      Returns:
      Worker team.
      Throws:
      IllegalStateException - (unchecked exception) Thrown if no worker team is executing this worker construct.
    • region

      public final WorkerRegion region()
      Returns the worker region of code within which a worker team is executing this worker construct.
      Returns:
      Worker region.
      Throws:
      IllegalStateException - (unchecked exception) Thrown if no worker team is executing this worker construct.
    • getThreadCount

      public final int getThreadCount()
      Determine the number of worker threads in the current process in the worker team executing this worker construct. This does not include the master thread if any.
      Returns:
      Number of worker threads in the current process.
      Throws:
      IllegalStateException - (unchecked exception) Thrown if no worker team is executing this worker construct.
    • getTotalThreadCount

      public final int getTotalThreadCount()
      Determine the total number of worker threads in all processes in the worker team executing this worker construct. This does not include the master thread.
      Returns:
      Number of worker threads in all processes.
      Throws:
      IllegalStateException - (unchecked exception) Thrown if no worker team is executing this worker construct.
    • getThreadIndex

      public final int getThreadIndex()
      Determine the index of the calling thread in the worker team executing this worker construct. Every worker thread in every process has a unique index, going from index 0 for the first thread in the first process to index K−1 for the last thread in the last process, where K is the total number of worker threads in all the processes. The master thread's index is −1.
      Returns:
      Index of the calling thread.
      Throws:
      IllegalStateException - (unchecked exception) Thrown if no worker team is executing this worker construct. Thrown if the thread calling getThreadIndex() is not part of the worker team executing this worker construct.
    • isMasterThread

      public final boolean isMasterThread()
      Determine if the calling thread is the master thread in the worker team executing this worker construct.
      Returns:
      True if the calling thread is the master thread, false if the calling thread is a worker thread.
      Throws:
      IllegalStateException - (unchecked exception) Thrown if no worker team is executing this worker construct. Thrown if the thread calling getThreadIndex() is not part of the worker team executing this worker construct.