edu.memphis.ccrg.lida.framework.tasks
Class RandomizingTaskSpawner

java.lang.Object
  extended by edu.memphis.ccrg.lida.framework.initialization.InitializableImpl
      extended by edu.memphis.ccrg.lida.framework.tasks.TaskSpawnerImpl
          extended by edu.memphis.ccrg.lida.framework.tasks.RandomizingTaskSpawner
All Implemented Interfaces:
Initializable, TaskSpawner

public class RandomizingTaskSpawner
extends TaskSpawnerImpl

A TaskSpawner which randomizes the execution of tasks. For each execution, a task's nextTicksPerRun is randomized using a uniform distribution.
To modify this distribution override the method randomizeTicksPerRun(long).

Author:
Javier Snaider, Ryan J. McCall

Constructor Summary
RandomizingTaskSpawner()
           
 
Method Summary
 void addTask(FrameworkTask task)
          First randomizes task's ticksPerRun and then adds and runs it.
 double getVariation()
          Gets variation
 void init()
          Sets the following parameter: variation type=double the amount of possible variation in a randomized value of ticksPerRun from its initial value
 long randomizeTicksPerRun(long ticksPerRun)
          Randomizes ticksPerRun by variation percent.
 void receiveFinishedTask(FrameworkTask task)
          First randomizes task's ticksPerRun and then adds and runs it then calls TaskSpawnerImpl.receiveFinishedTask(FrameworkTask).
 void setVariation(double v)
          Sets variation
 
Methods inherited from class edu.memphis.ccrg.lida.framework.tasks.TaskSpawnerImpl
addTasks, cancelTask, containsTask, getRunningTasks, getTasks, processResults, setTaskManager
 
Methods inherited from class edu.memphis.ccrg.lida.framework.initialization.InitializableImpl
containsParameter, getParam, getParameters, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.memphis.ccrg.lida.framework.initialization.Initializable
containsParameter, getParam, getParameters, init
 

Constructor Detail

RandomizingTaskSpawner

public RandomizingTaskSpawner()
Method Detail

init

public void init()
Sets the following parameter: variation type=double the amount of possible variation in a randomized value of ticksPerRun from its initial value

Specified by:
init in interface Initializable
Overrides:
init in class InitializableImpl

getVariation

public double getVariation()
Gets variation

Returns:
the variation

setVariation

public void setVariation(double v)
Sets variation

Parameters:
v - the variation to set

randomizeTicksPerRun

public long randomizeTicksPerRun(long ticksPerRun)
Randomizes ticksPerRun by variation percent. Uses uniform distribution for random value.

Parameters:
ticksPerRun - parameter to randomize
Returns:
new non-zero ticksPerRun value

addTask

public void addTask(FrameworkTask task)
First randomizes task's ticksPerRun and then adds and runs it.

Specified by:
addTask in interface TaskSpawner
Overrides:
addTask in class TaskSpawnerImpl
Parameters:
task - the task to add.

receiveFinishedTask

public void receiveFinishedTask(FrameworkTask task)
First randomizes task's ticksPerRun and then adds and runs it then calls TaskSpawnerImpl.receiveFinishedTask(FrameworkTask).

Specified by:
receiveFinishedTask in interface TaskSpawner
Overrides:
receiveFinishedTask in class TaskSpawnerImpl
Parameters:
task - finished FrameworkTask