gugga.sequence.TaskManager Class Reference

Inheritance diagram for gugga.sequence.TaskManager:

Inheritance graph
[legend]
Collaboration diagram for gugga.sequence.TaskManager:

Collaboration graph
[legend]
List of all members.

Detailed Description

TaskManager is a facade encapsulating the complexity in a certain web of tasks. The relationships between tasks could be very comlpex, especially if there are subsets of asynchronous tasks, waiting for completed or other kinds of events fired from other tasks, that could be also asynchronous.

Behind the scenes TaskManager is a container for TaskManagerItem items and a list of final preconditions that should be met in order to fire the completed event.

TaskManager completes right after its start, when no final tasks or final preconditions were specified.

Author:
Barni
See also:
TaskManagerItem

PreconditionsTask

Definition at line 48 of file TaskManager.as.

Public Member Functions

function get ImmediatelyInterruptable ()
function get Tasks ()
function get MarkedTasks ()
function TaskManager (aAccepting:Boolean)
function start ()
function isRunning ()
function isImmediatelyInterruptable ()
function interrupt ()
function reset ()
function acceptPrecondition (aPrecondition:EventDescriptor)
function acceptEventSource (aEventSource:IEventDispatcher)
function acceptAll ()
function ignorePrecondition (aPrecondition:EventDescriptor)
function ignoreEventSource (aEventSource:IEventDispatcher)
function ignoreAll ()
function addStartingTask (aTask:ITask)
function addStartingTasks (aTasks:Array)
function setStartingTask (aTask:ITask)
function revokeStartingTask (aTask:ITask)
function addTaskWithPredecessor (aTask:ITask, aPredecessor:ITask)
function addTaskWithPredecessors (aTask:ITask, aPredecessors:Array)
function addTaskPredecessor (aTask:ITask, aPredecessor:ITask)
function addTaskPredecessors (aTask:ITask, aPredecessors:Array)
function removeTaskPredecessor (aTask:ITask, aPredecessor:ITask)
function addTaskWithPrecondition (aTask:ITask, aPrecondition:EventDescriptor)
function addTaskWithPreconditions (aTask:ITask, aPreconditions:Array)
function addTaskPrecondition (aTask:ITask, aPrecondition:EventDescriptor)
function addTaskPreconditions (aTask:ITask, aPreconditions:Array)
function removeTaskPrecondition (aTask:ITask, aPrecondition:EventDescriptor)
function addFinalPrecondition (aPrecondition:EventDescriptor)
function addFinalPreconditions (aPreconditions:Array)
function removeFinalPrecondition (aPrecondition:EventDescriptor)
function setFinalTask (aTask:ITask)
function revokeFinalTask (aTask:ITask)
function markTask (aTask:ITask, aMarker:String)
function getMarkedTask (aMarker:String)
function getTaskMarker (aTask:ITask)
function removeTask (aTask:ITask)
function replaceTask (aTask:ITask, aNewTask:ITask)

Private Member Functions

function createItem (aTask:ITask)
function findItem (aTask:ITask)
function findItemKey (aTask:ITask)
function removeItem (aTask:ITask)
function removeAssociatedPreconditions (aTask:ITask)
function replaceAssociatedPreconditions (aTask:ITask, aNewTask:ITask)
function generateKey ()
function applyNewItemState (aItem:TaskManagerItem)
function onFinalPreconditionsMet ()
function onItemsInterrupted ()

Private Attributes

var mItems: HashTable
var mFinalPreconditions: PreconditionsTask
var mAccepting: Boolean
var mMarkedTasks: HashTable
var mIsRunning: Boolean = false


Constructor & Destructor Documentation

function gugga.sequence.TaskManager.TaskManager ( aAccepting:Boolean   ) 

We can set the accepting state of the TaskManager through this constructor.

The constructor will create an accepting TaskManager by default if no argument is specified.

Parameters:
Boolean accepting state(accepting or unaccepting)
See also:
acceptAll()

ignoreAll()

Definition at line 90 of file TaskManager.as.


Member Function Documentation

function get gugga.sequence.TaskManager.ImmediatelyInterruptable (  ) 

Definition at line 59 of file TaskManager.as.

function get gugga.sequence.TaskManager.Tasks (  ) 

Definition at line 64 of file TaskManager.as.

function get gugga.sequence.TaskManager.MarkedTasks (  ) 

Definition at line 74 of file TaskManager.as.

function gugga.sequence.TaskManager.start (  ) 

The start() method is responsible for the following actions:

Definition at line 119 of file TaskManager.as.

References gugga.events.EventDispatcher.dispatchEvent().

Here is the call graph for this function:

function gugga.sequence.TaskManager.isRunning (  ) 

Definition at line 133 of file TaskManager.as.

function gugga.sequence.TaskManager.isImmediatelyInterruptable (  ) 

isImmediatelyInterruptable() cheches for each TaskManagerItem behind the facade whether it is immediately interruptable. isImmediatelyInterruptable() will return true only if all of the items are immediately interuptable, and will return false if any of these items are not immediately interruptable.

Returns:
whether the TaskManager task is immediately interruptable

Definition at line 148 of file TaskManager.as.

function gugga.sequence.TaskManager.interrupt (  ) 

interrupt() method will interrupt all of the TaskManagerItem items.

It will check for each TaskManagerItem items whether they are immediately interruptable and for those that are not it creates a PreconditionsTask that will complete, only if all of those items raise the interrupted event.

TaskManager will fire the interrupted event when all of its items are interrupted, but it will wait the forementioned PreconditionsTask to complete, if any of the items are not immediately interruptable.

Definition at line 177 of file TaskManager.as.

References gugga.events.EventDispatcher.dispatchEvent().

Here is the call graph for this function:

function gugga.sequence.TaskManager.reset (  ) 

Resets every TaskManagerItem

Definition at line 213 of file TaskManager.as.

function gugga.sequence.TaskManager.acceptPrecondition ( aPrecondition:EventDescriptor   ) 

Every TaskManagerItem will accept for the specified precondition.

Parameters:
EventDescriptor precondition that will be accepted

Definition at line 228 of file TaskManager.as.

function gugga.sequence.TaskManager.acceptEventSource ( aEventSource:IEventDispatcher   ) 

Every TaskManagerItem will accept for all of the preconditions comming from the specified event source.

Parameters:
IEventDispatcher event source for preconditions, that will be accepted

Definition at line 243 of file TaskManager.as.

function gugga.sequence.TaskManager.acceptAll (  ) 

Every TaskManagerItem will accept for all of the preconditions that are associated with it.

Definition at line 256 of file TaskManager.as.

function gugga.sequence.TaskManager.ignorePrecondition ( aPrecondition:EventDescriptor   ) 

Every TaskManagerItem will ignore the specified precondition.

Parameters:
EventDescriptor precondition that will be ignored

Definition at line 272 of file TaskManager.as.

function gugga.sequence.TaskManager.ignoreEventSource ( aEventSource:IEventDispatcher   ) 

Every TaskManagerItem will ignore all of the preconditions comming from the specified event source.

Parameters:
IEventDispatcher event source for preconditions, that will be ignored

Definition at line 287 of file TaskManager.as.

function gugga.sequence.TaskManager.ignoreAll (  ) 

Every TaskManagerItem will ignore all of the preconditions that are associated with it.

Definition at line 300 of file TaskManager.as.

function gugga.sequence.TaskManager.addStartingTask ( aTask:ITask   ) 

addStartingTasks(aTask : ITask) will create and add new TaskManagerItem item to the TaskManager and exception will be raised if the specified task is already associated with existing TaskManagerItem. It will also add a precondition to wait for start event from the TaskManager task, in order to start the TaskManagerItem item's execution. The associated TaskManagerItem items will start only if the TaskManager task is started, and never before it.

Parameters:
ITask new starting task

Definition at line 323 of file TaskManager.as.

function gugga.sequence.TaskManager.addStartingTasks ( aTasks:Array   ) 

addStartingTasks(aTasks : Array) will create and add new TaskManagerItem items to the TaskManager and exception will be raised if any of the specified tasks is already associated with existing TaskManagerItem. It will also add a precondition to wait for start event from the TaskManager task, in order to start the TaskManagerItem item's execution. The associated TaskManagerItem items will start only if the TaskManager task is started, and never before it.

Parameters:
Array array of ITask items, that we want to be starting tasks

Definition at line 341 of file TaskManager.as.

function gugga.sequence.TaskManager.setStartingTask ( aTask:ITask   ) 

Checks whether there is an associated TaskManagerItem with the specified task. If true, it adds to the associated TaskManagerItem a precondition to wait for start event from the TaskManager task, in order to start its execution too. But if the check fails it will raise an exception - the specified task is not associated with any TaskManagerItem items.

The associated TaskManagerItem item will start only if the TaskManager task is started, and never before it.

Parameters:
ITask existing task

Definition at line 363 of file TaskManager.as.

function gugga.sequence.TaskManager.revokeStartingTask ( aTask:ITask   ) 

Checks whether there is an associated TaskManagerItem with the specified task. If true, it removes from the associated TaskManagerItem the precondition to wait for start event from the TaskManager task, in order to start its execution too. But if the check fails it will raise an exception - the specified task is not associated with any TaskManagerItem items.

The associated TaskManagerItem item will no longer wait TaskManager task's start, in order to start its execution.

Parameters:
ITask existing task

Definition at line 387 of file TaskManager.as.

function gugga.sequence.TaskManager.addTaskWithPredecessor ( aTask:ITask  ,
aPredecessor:ITask   
)

If no TaskManagerItem is associated with the specified task, the method will add a new TaskManagerItem to the TaskManager. It will add to the new TaskManagerItem a precondition waiting for completed event, comming from the specified predecessor task.

Parameters:
ITask new task or a task already associated with a TaskManagerItem
ITask predecessor, that should complete in order to start the specified task

Definition at line 409 of file TaskManager.as.

function gugga.sequence.TaskManager.addTaskWithPredecessors ( aTask:ITask  ,
aPredecessors:Array   
)

If no TaskManagerItem is associated with the specified task, the method will add a new TaskManagerItem to the TaskManager. For each predecessor task in the specified Array of predecessors creates a precondition waiting for completed event, comming from this predecessor task. Then these newly created preconditions are added to the associated TaskManagerItem

Parameters:
ITask new task or a task already associated with a TaskManagerItem
Array array of predecessor tasks, that should complete in order to start the specified task

Definition at line 429 of file TaskManager.as.

function gugga.sequence.TaskManager.addTaskPredecessor ( aTask:ITask  ,
aPredecessor:ITask   
)

Analogous to the addTaskWithPredecessor() method. The only difference is that addTaskPredecessor() will not add a new TaskManagerItem if there is no associated TaskManagerItem with the specified task. On the contrary, it will raise an exception - the specified task does not exist.

Parameters:
ITask task already associated with a TaskManagerItem
Array array of predecessor tasks, that should complete in order to start the specified task
See also:
addTaskWithPredecessors()

Definition at line 455 of file TaskManager.as.

function gugga.sequence.TaskManager.addTaskPredecessors ( aTask:ITask  ,
aPredecessors:Array   
)

Analogous to the addTaskWithPredecessors() method. The only difference is that addTaskPredecessors() will not add a new TaskManagerItem if there is no associated TaskManagerItem with the specified task. On the contrary, it will raise an exception - the specified task does not exist.

Parameters:
ITask task already associated with a TaskManagerItem
Array array of predecessor tasks, that should complete in order to start the specified task
See also:
addTaskWithPredecessors()

Definition at line 475 of file TaskManager.as.

function gugga.sequence.TaskManager.removeTaskPredecessor ( aTask:ITask  ,
aPredecessor:ITask   
)

Removes for the specified task the preconditon that will be met when the specified predecessor task is completed. The specified task will no longer wait the completion of the predecessor.

Parameters:
ITask the task that will no longer wait for the predecessor's completion
ITask the predecessor task

Definition at line 497 of file TaskManager.as.

function gugga.sequence.TaskManager.addTaskWithPrecondition ( aTask:ITask  ,
aPrecondition:EventDescriptor   
)

If no TaskManagerItem is associated with the specified task, the method will add new TaskManagerItem to the TaskManager. Then the specified precondition is added to the new TaskManagerItem.

An exception will be raised if there is an existing TaskManagerItem associated with the specified task.

Parameters:
ITask new task or a task already associated with a TaskManagerItem
Array array of preconditions, that should be met

Definition at line 518 of file TaskManager.as.

function gugga.sequence.TaskManager.addTaskWithPreconditions ( aTask:ITask  ,
aPreconditions:Array   
)

If no TaskManagerItem is associated with the specified task, the method will add a new TaskManagerItem to the TaskManager. Then the preconditions in the specified array are added to the new TaskManagerItem.

An exception will be raised if there is an existing TaskManagerItem associated with the specified task.

Parameters:
ITask new task or a task already associated with a TaskManagerItem
Array array of preconditions, that should be met

Definition at line 543 of file TaskManager.as.

function gugga.sequence.TaskManager.addTaskPrecondition ( aTask:ITask  ,
aPrecondition:EventDescriptor   
)

Adds the specified precondition to the associated with the specified task TaskManagerItem. If no TaskManagerItem is associated with the specified task, the method will raise an exception.

Parameters:
ITask task already associated with a TaskManagerItem
EventDescriptor precondition

Definition at line 567 of file TaskManager.as.

function gugga.sequence.TaskManager.addTaskPreconditions ( aTask:ITask  ,
aPreconditions:Array   
)

Adds the specified preconditions to the associated with the specified task TaskManagerItem. If no TaskManagerItem is associated with the specified task, the method will raise an exception.

Parameters:
ITask task already associated with a TaskManagerItem
Array preconditions

Definition at line 587 of file TaskManager.as.

function gugga.sequence.TaskManager.removeTaskPrecondition ( aTask:ITask  ,
aPrecondition:EventDescriptor   
)

Removes the specified precondition if there is an associated TaskManagerItem with the specified task.

Parameters:
ITask task already associated with a TaskManagerItem
EventDescriptor precondition

Definition at line 609 of file TaskManager.as.

function gugga.sequence.TaskManager.addFinalPrecondition ( aPrecondition:EventDescriptor   ) 

Adds precondition to the final preconditions list.

TaskManager completes right after its start, when no final tasks or final preconditions were specified.

Parameters:
Precondition 

Definition at line 628 of file TaskManager.as.

function gugga.sequence.TaskManager.addFinalPreconditions ( aPreconditions:Array   ) 

Adds preconditions to the final preconditions list.

TaskManager completes right after its start, when no final tasks or final preconditions were specified.

Parameters:
Array array of preconditions

Definition at line 641 of file TaskManager.as.

function gugga.sequence.TaskManager.removeFinalPrecondition ( aPrecondition:EventDescriptor   ) 

Removes the specified precondition from the final preconditions list.

Parameters:
EventDescriptor precondition

Definition at line 654 of file TaskManager.as.

function gugga.sequence.TaskManager.setFinalTask ( aTask:ITask   ) 

Adds a precondition to the final preconditions list. The new precondition will be met, when the specified task is completed.

TaskManager completes right after its start, when no final tasks or final preconditions were specified.

Parameters:
ITask task, that should complete in order to meet one of the final preconditions for the TaskManager task

Definition at line 668 of file TaskManager.as.

function gugga.sequence.TaskManager.revokeFinalTask ( aTask:ITask   ) 

Removes the precondition that should be met, when the specified task is completed. This precondition will be no longer in the final preconditions list.

ITask task, that no longer should be completed in order to meet the final preconditions for the TaskManager task

Definition at line 680 of file TaskManager.as.

function gugga.sequence.TaskManager.markTask ( aTask:ITask  ,
aMarker:String   
)

Definition at line 685 of file TaskManager.as.

function gugga.sequence.TaskManager.getMarkedTask ( aMarker:String   ) 

Definition at line 690 of file TaskManager.as.

function gugga.sequence.TaskManager.getTaskMarker ( aTask:ITask   ) 

Definition at line 695 of file TaskManager.as.

function gugga.sequence.TaskManager.removeTask ( aTask:ITask   ) 

If TaskManagerItem is associated with the specified task, it will remove this item and all preconditions in the TaskManager associated with the specified task.

Parameters:
ITask task that will be no longer tracked in the TaskManager

Definition at line 707 of file TaskManager.as.

function gugga.sequence.TaskManager.replaceTask ( aTask:ITask  ,
aNewTask:ITask   
)

If TaskManagerItem is associated with the specified task, it will replase its scheduled task with the new one. It will also replace the event sources of the preconditions that are listening for events comming from the old task. The new task will be the new source for them.

Parameters:
ITask old task
ITask new task

Definition at line 727 of file TaskManager.as.

function gugga.sequence.TaskManager.createItem ( aTask:ITask   )  [private]

Definition at line 739 of file TaskManager.as.

function gugga.sequence.TaskManager.findItem ( aTask:ITask   )  [private]

Definition at line 747 of file TaskManager.as.

function gugga.sequence.TaskManager.findItemKey ( aTask:ITask   )  [private]

Definition at line 759 of file TaskManager.as.

function gugga.sequence.TaskManager.removeItem ( aTask:ITask   )  [private]

Definition at line 774 of file TaskManager.as.

function gugga.sequence.TaskManager.removeAssociatedPreconditions ( aTask:ITask   )  [private]

Definition at line 783 of file TaskManager.as.

function gugga.sequence.TaskManager.replaceAssociatedPreconditions ( aTask:ITask  ,
aNewTask:ITask   
) [private]

Definition at line 793 of file TaskManager.as.

function gugga.sequence.TaskManager.generateKey (  )  [private]

Definition at line 805 of file TaskManager.as.

function gugga.sequence.TaskManager.applyNewItemState ( aItem:TaskManagerItem   )  [private]

TODO: Is this the only case? Shouldn't be revised?

Definition at line 815 of file TaskManager.as.

function gugga.sequence.TaskManager.onFinalPreconditionsMet (  )  [private]

Definition at line 826 of file TaskManager.as.

References gugga.events.EventDispatcher.dispatchEvent().

Here is the call graph for this function:

function gugga.sequence.TaskManager.onItemsInterrupted (  )  [private]

Definition at line 833 of file TaskManager.as.

References gugga.events.EventDispatcher.dispatchEvent().

Here is the call graph for this function:


Member Data Documentation

var gugga.sequence.TaskManager.mItems [private]

Definition at line 52 of file TaskManager.as.

var gugga.sequence.TaskManager.mFinalPreconditions [private]

Definition at line 53 of file TaskManager.as.

var gugga.sequence.TaskManager.mAccepting [private]

Definition at line 54 of file TaskManager.as.

var gugga.sequence.TaskManager.mMarkedTasks [private]

Definition at line 55 of file TaskManager.as.

var gugga.sequence.TaskManager.mIsRunning [private]

Definition at line 57 of file TaskManager.as.


Generated on Fri May 11 17:14:44 2007 for GuggaFramework by  doxygen 1.5.2