edu.memphis.ccrg.lida.framework.tasks
Interface TaskSpawner

All Superinterfaces:
Initializable
All Known Implementing Classes:
RandomizingTaskSpawner, TaskSpawnerImpl

public interface TaskSpawner
extends Initializable

TaskSpawners manage FrameworkTask objects. Maintains a Collection of all added tasks. Provides method to process the result of a FrameworkTask.

Author:
Ryan J. McCall

Method Summary
 void addTask(FrameworkTask task)
          Adds and runs supplied FrameworkTask.
 void addTasks(java.util.Collection<? extends FrameworkTask> tasks)
          Adds and runs supplied FrameworkTasks.
 boolean cancelTask(FrameworkTask task)
          Cancels specified task if it exists in this TaskSpawner Task is removed from TaskSpawner and canceled in the TaskManager.
 boolean containsTask(FrameworkTask t)
          Returns whether this TaskSpawner manages this task.
 java.util.Collection<FrameworkTask> getRunningTasks()
          Deprecated. The returned tasks may not have TaskStatus.RUNNING. Replaced by getTasks().
 java.util.Collection<FrameworkTask> getTasks()
          Returns the FrameworkTask objects controlled by this TaskSpawner.
 void receiveFinishedTask(FrameworkTask task)
          This method receives a task that has finished.
 void setTaskManager(TaskManager tm)
          Set the TaskManager this TaskSpawner will use to actually run the tasks.
 
Methods inherited from interface edu.memphis.ccrg.lida.framework.initialization.Initializable
containsParameter, getParam, getParameters, init, init
 

Method Detail

setTaskManager

void setTaskManager(TaskManager tm)
Set the TaskManager this TaskSpawner will use to actually run the tasks.

Parameters:
tm - the TaskManager of the system.

addTask

void addTask(FrameworkTask task)
Adds and runs supplied FrameworkTask.

Parameters:
task - the task to add.

addTasks

void addTasks(java.util.Collection<? extends FrameworkTask> tasks)
Adds and runs supplied FrameworkTasks.

Parameters:
tasks - a collection of tasks to be run.

receiveFinishedTask

void receiveFinishedTask(FrameworkTask task)
This method receives a task that has finished. TaskSpawners can choose what to do with the FrameworkTask each time it finishes running. Generally the FrameworkTask's TaskStatus determines this action.

Parameters:
task - finished FrameworkTask

cancelTask

boolean cancelTask(FrameworkTask task)
Cancels specified task if it exists in this TaskSpawner Task is removed from TaskSpawner and canceled in the TaskManager. This is only possible if the tick for which the task is scheduled has not been reached.

Parameters:
task - The task to cancel.
Returns:
true if the task was canceled, false otherwise
See Also:
TaskManager.cancelTask(FrameworkTask)

containsTask

boolean containsTask(FrameworkTask t)
Returns whether this TaskSpawner manages this task.

Parameters:
t - a FrameworkTask
Returns:
true if this TaskSpawner contains a task with task's id

getRunningTasks

@Deprecated
java.util.Collection<FrameworkTask> getRunningTasks()
Deprecated. The returned tasks may not have TaskStatus.RUNNING. Replaced by getTasks().

Returns a UnmodifiableCollection that contains the FrameworkTasks in this TaskSpawner. Tasks' TaskStatus may or may not be running. Use getTasks() instead.

Returns:
collection of running tasks.

getTasks

java.util.Collection<FrameworkTask> getTasks()
Returns the FrameworkTask objects controlled by this TaskSpawner.

Returns:
a Collection FrameworkTasks.