pt.runtime
Class ParaTask

java.lang.Object
  extended by pt.runtime.ParaTask

public class ParaTask
extends java.lang.Object

Helper methods for the ParaTask runtime. This class contains various functions to set up the ParaTask runtime, etc.

All applications making use of the ParaTask features should invoke init() early in the main method. This will initialise various aspects of the ParaTask runtime.

Author:
Nasser Giacaman, Oliver Sinnen

Nested Class Summary
static class ParaTask.ScheduleType
          Enum representing the possible schedules that ParaTask supports.
static class ParaTask.ThreadPoolType
          Enum representing the possible thread pool types that ParaTask supports.
 
Method Summary
static int activeInteractiveTaskCount()
          Returns a count of the number of active interactive tasks.
static java.util.ArrayList<TaskID> allTasksInGroup(TaskIDGroup group)
          A recursive convenience function that digs into the TaskIDGroup and returns all the individual TaskIDs.
static java.util.ArrayList<TaskID> allTasksInList(java.util.ArrayList<TaskID> list)
          Flattens a list of TaskIDs.
static int getActiveCount(ParaTask.ThreadPoolType threadPoolType)
           
static java.lang.Thread getEDT()
           
static ParaTask.ScheduleType getScheduleType()
          Returns the schedule being used in the runtime.
static int getThreadPoolSize(ParaTask.ThreadPoolType threadPoolType)
          Returns the size of the thread pool.
static void init()
          To be executed by the main thread (i.e.
static void setScheduling(ParaTask.ScheduleType type)
          Set the scheduling scheme.
static void setThreadPoolSize(ParaTask.ThreadPoolType threadPoolType, int size)
          Set the size of the thread pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getEDT

public static java.lang.Thread getEDT()

setThreadPoolSize

public static void setThreadPoolSize(ParaTask.ThreadPoolType threadPoolType,
                                     int size)
Set the size of the thread pool. To have any effect, this must be executed very early before ParaTask creates the runtime.

Parameters:
size -

setScheduling

public static void setScheduling(ParaTask.ScheduleType type)
Set the scheduling scheme. This only has an effect if no tasks have been executed yet (i.e. must be called before the taskpool is created).

Parameters:
type - The schedule to use.

getScheduleType

public static ParaTask.ScheduleType getScheduleType()
Returns the schedule being used in the runtime.

Returns:
The schedule being used.

getThreadPoolSize

public static int getThreadPoolSize(ParaTask.ThreadPoolType threadPoolType)
Returns the size of the thread pool.

Returns:
The thread pool size.

getActiveCount

public static int getActiveCount(ParaTask.ThreadPoolType threadPoolType)

activeInteractiveTaskCount

public static int activeInteractiveTaskCount()
Returns a count of the number of active interactive tasks. Useful if need to decide whether a task should be invoked interactively or not (e.g. to limit thread count).

Returns:
The number of active interactive tasks.

init

public static void init()
To be executed by the main thread (i.e. inside the main method). Registers the main thread and event dispatch thread with ParaTask, as well as other ParaTask runtime settings.


allTasksInList

public static java.util.ArrayList<TaskID> allTasksInList(java.util.ArrayList<TaskID> list)
Flattens a list of TaskIDs. Only has an effect if some of the TaskIDs were actually TaskIDGroups.

Parameters:
list - Input list of TaskIDs (with potentially some TaskIDGroups)
Returns:
A list containing only TaskIDs (i.e. expanding the TaskIDGroups)
See Also:
allTasksInGroup(TaskIDGroup)

allTasksInGroup

public static java.util.ArrayList<TaskID> allTasksInGroup(TaskIDGroup group)
A recursive convenience function that digs into the TaskIDGroup and returns all the individual TaskIDs.

Returns:
the TaskIDs inside group placed inside a new ArrayList
See Also:
allTasksInList(ArrayList)