Package edu.rit.pj
Class WorkerConstruct
java.lang.Object
edu.rit.pj.WorkerConstruct
- Direct Known Subclasses:
WorkerForLoop
,WorkerIteration
,WorkerRegion
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
-
Method Summary
Modifier and TypeMethodDescriptionfinal 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.final WorkerRegion
region()
Returns the worker region of code within which a worker team is executing this worker construct.final WorkerTeam
team()
Returns the worker team that is executing this worker construct.
-
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
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
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 callinggetThreadIndex()
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 callinggetThreadIndex()
is not part of the worker team executing this worker construct.
-