|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.runtime.CurrentTask
public class CurrentTask
Helper methods for the currently executing task. This class contains various functions in regards
to the current task.
The methods in this class are only applicable to the currently executed task, and will therefore
throw a RuntimeException
when called from a non-task. To inquire if within a task, programmers
may use insideTask()
.
Method Summary | ||
---|---|---|
static void |
barrier()
Barrier synchronisation for multi-tasks. |
|
static boolean |
cancelRequested()
The current task checks to see if it has been requested to cancel. |
|
static TaskID |
currentTaskID()
Return the current TaskID associated with the currently executing task. |
|
static int |
currentThreadID()
Returns the ParaTask thread's ID. |
|
static int |
currentThreadLocalID()
|
|
static int |
getProgress()
Returns the progress of the currently executed task. |
|
static int |
globalID()
Returns the current task's global ID. |
|
static boolean |
insideTask()
Inquire as to whether the current code being executed is inside a task. |
|
static boolean |
isMultiTask()
|
|
static boolean |
isOneoffTask()
|
|
static boolean |
isSubTask()
|
|
static int |
multiTaskSize()
Returns the current task's multi-task size. |
|
static
|
publishInterim(E interimResult)
Publish intermediate results. |
|
static int |
relativeID()
All tasks have a relative ID. |
|
static void |
setProgress(int progress)
Updates the progress of the currently executing task. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static int currentThreadID()
java.lang.RuntimeException
- if not called from within a ParaTask task.public static int currentThreadLocalID()
java.lang.RuntimeException
- if not called from within a ParaTask task.public static boolean insideTask()
TASK int computeTask(int value) {
return compute(value);
}
public int compute(int value) {
...
if (ParaTask.insideTask()) {
// this method is being executed as a ParaTask task
} else {
// this method is not being executed as a ParaTask task
// (maybe the event dispatch thread, main thread, or another user-defined thread)
}
...
}
true
if the currently inside a task, false
otherwise.public static int multiTaskSize()
java.lang.RuntimeException
- if not called from within a ParaTask task.public static int getProgress()
java.lang.RuntimeException
- if not called from within a ParaTask task.TaskID.setProgress(int)
,
setProgress(int)
public static void setProgress(int progress)
progress
- The new progress of the currently executing task.
java.lang.RuntimeException
- if not called from within a ParaTask task.TaskID.getProgress()
,
getProgress()
public static TaskID currentTaskID()
java.lang.RuntimeException
- if not called from within a ParaTask task.public static int globalID()
java.lang.RuntimeException
- if not called from within a ParaTask task.TaskID.globalID()
public static int relativeID()
java.lang.RuntimeException
- if not called from within a ParaTask task.TaskID.relativeID()
public static boolean cancelRequested()
true
if the current task has been asked to cancel, false
otherwise.
java.lang.RuntimeException
- if not called from within a ParaTask task.TaskID.cancelAttempt()
,
TaskID.cancelRequested()
public static <E> void publishInterim(E interimResult)
notifyInterim
or notifyInterimGUI
clause), this is the method to publish those
results to them.
E
- The type of the interim result to be publishedinterimResult
- The interim result being published.
java.lang.RuntimeException
- if not called from within a ParaTask task.public static void barrier() throws java.lang.InterruptedException, java.util.concurrent.BrokenBarrierException
java.lang.InterruptedException
java.util.concurrent.BrokenBarrierException
java.lang.RuntimeException
- if not called from within a ParaTask task.public static boolean isOneoffTask()
public static boolean isMultiTask()
public static boolean isSubTask()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |