Packagecom.developmentarc.framework.datastructures.tasks
Classpublic class TaskGroup
InheritanceTaskGroup Inheritance flash.events.EventDispatcher
ImplementsITaskGroup

The TaskGroup is a data structure that allows a set of tasks to be grouped together as a set. The TaskGroup can then be added to the TaskController and all of the grouped task will be exectued first before the next task in the controller is processed.

When an override is provided to the task controller, the task group acts as a parent type and the task group will remove all tasks if the provided override matches the group type. The individual type of the task is ignored in this case.

Tasks added to the group can override the same was as if they were added directly to the TaskController. Upon adding a task, the TaskGroup will evaluate the tasks overrides and the tasks selfOverrding boolean and will take appropriate action. The functionality is similar to the TaskController's override mechinism.

TaskGroups can NOT be added to other TaskGroups at this time. A generic error will be thrown if this occurs

Note: Once a TaskGroup has been added to the TaskController and queued, the TaskGroup will no longer accept additional Task and will throw a generic error.

See also

com.developmentarc.framework.controllers.TaskController


Public Properties
 PropertyDefined by
  hasTask : Boolean
[read-only] Determines if TaskGroup contains tasks or not.
TaskGroup
  isBlocker : Boolean
[read-only] Determines if the TaskGroup blocks all other items in the TaskController.
TaskGroup
  phase : String
[read-only] Returns the current phase of the TaskGroup, such as started, etc.
TaskGroup
  priority : uint
[read-only] The priority value of the TaskGroup.
TaskGroup
  ready : Boolean
[read-only] TaskGroups are always ready and will return true
TaskGroup
  selfOverride : Boolean
Defines whether the group is self-overriding or not.
TaskGroup
  taskOverrides : Array
An array of types of tasks / task groups that this task group should override in the TaskController.
TaskGroup
  tasks : Array
Returns all tasks still in queue or that have been proccessed
TaskGroup
  type : String
[read-only] The current type of TaskGroup.
TaskGroup
  uid : Object
[read-only] Id of the group instance.
TaskGroup
Protected Properties
 PropertyDefined by
  currentPhase : String = "GROUP_NOT_QUEUED"
The current phase of the group.
TaskGroup
  processedQueue : PriorityQueue
The tasks that have been started, cancelled, ignored or errored out.
TaskGroup
  taskQueue : PriorityQueue
The current tasks that have been added to the Group but have not been started() yet.
TaskGroup
Public Methods
 MethodDefined by
  
TaskGroup(type:String, priority:int = 5, uid:Object = null, selfOverride:Boolean = false, blocking:Boolean = false)
Constructor.
TaskGroup
  
addTask(task:ITask):void

Adds a single task to the task group.

TaskGroup
  
cancel():void
Method is used to change groups phase to canel and dispath event.
TaskGroup
  
getTaskIndex(task:ITask):int
Returns the index of a task in the taskQueue.
TaskGroup
  
ignore():void
Method is used to change groups phase to ignore and dispath event.
TaskGroup
  
inQueue():void
Method is used to change groups phase to queued and dispath event.
TaskGroup
  
Method is used to change groups phase to wait for ready and dispath event.
TaskGroup
  
Returns the next task in the group with the highest priority task first.
TaskGroup
  
pause():void
Method is used to change groups phase to pause and dispath event.
TaskGroup
  
Removes all tasks from the group.
TaskGroup
  
removeTask(task:ITask):void
Removes all instances of a specific task from the group.
TaskGroup
  
start():void
Method is used to change groups phase to start and dispath event.
TaskGroup
Protected Methods
 MethodDefined by
  
applyOverrides(newTask:ITask):Boolean

Used to find and remove any tasks in the current group queue that are overriden by a new task that has been added to the group.

TaskGroup
  
Method handles group tasks that have been completed, cancel or errored.
TaskGroup
Public Constants
 ConstantDefined by
  GROUP_NOT_QUEUED : String = "GROUP_NOT_QUEUED"
[static] The default phase value of a group when it is first constructed but not added to the TaskController.
TaskGroup
Property detail
currentPhaseproperty
protected var currentPhase:String = "GROUP_NOT_QUEUED"

The current phase of the group.

hasTaskproperty 
hasTask:Boolean  [read-only]

Determines if TaskGroup contains tasks or not.

Implementation
    public function get hasTask():Boolean
isBlockerproperty 
isBlocker:Boolean  [read-only]

Determines if the TaskGroup blocks all other items in the TaskController. If the TaskGroup is set as a blocking task, the controller will load no more items from the queue until this group is complete, cancelled or errors. The default is false.

Implementation
    public function get isBlocker():Boolean
phaseproperty 
phase:String  [read-only]

Returns the current phase of the TaskGroup, such as started, etc.

Implementation
    public function get phase():String
priorityproperty 
priority:uint  [read-only]

The priority value of the TaskGroup. 0 is the highest priority and uint.MAX_VALUE is the lowest priority.

Implementation
    public function get priority():uint
processedQueueproperty 
protected var processedQueue:PriorityQueue

The tasks that have been started, cancelled, ignored or errored out.

readyproperty 
ready:Boolean  [read-only]

TaskGroups are always ready and will return true

Implementation
    public function get ready():Boolean
selfOverrideproperty 
selfOverride:Boolean  [read-write]

Defines whether the group is self-overriding or not. When a group is self-overriding then when the group is added to the TaskController the TaskController will determine if the group already exists in the queue and if so then it will be removed from the queue.

Implementation
    public function get selfOverride():Boolean
    public function set selfOverride(value:Boolean):void
taskOverridesproperty 
taskOverrides:Array  [read-write]

An array of types of tasks / task groups that this task group should override in the TaskController. When a task group is added to the controller, the controller uses the taskOverrides list to determine what tasks or other groups should be removed from the current queue.

Implementation
    public function get taskOverrides():Array
    public function set taskOverrides(value:Array):void
taskQueueproperty 
protected var taskQueue:PriorityQueue

The current tasks that have been added to the Group but have not been started() yet.

tasksproperty 
tasks:Array  [read-write]

Returns all tasks still in queue or that have been proccessed

Implementation
    public function get tasks():Array
    public function set tasks(value:Array):void
typeproperty 
type:String  [read-only]

The current type of TaskGroup. The type defines how task overrides are applied when the group is in the queue. If a task or task group overrides the matching type of the group, the entire group is removed from the queue.

Implementation
    public function get type():String
uidproperty 
uid:Object  [read-only]

Id of the group instance. Used in applying self overrides.

Implementation
    public function get uid():Object
Constructor detail
TaskGroup()constructor
public function TaskGroup(type:String, priority:int = 5, uid:Object = null, selfOverride:Boolean = false, blocking:Boolean = false)

Constructor. Sets the groups type and priority.

Parameters
type:String — The type of Task
 
priority:int (default = 5) — The priority of the TaskGroup inside of the TaskController. Default is 5. Lower the number the higher the priority.
 
uid:Object (default = null) — The id set to this group. uid can be of any type. Default is null
 
selfOverride:Boolean (default = false) — Boolean indicating if the TaskGroup can override other TaskGroups of the same type with same uid. Default false
 
blocking:Boolean (default = false)
Method detail
addTask()method
public function addTask(task:ITask):void

Adds a single task to the task group. The added task is stored by its priority within the task group.

A group can NOT be added to another group. Error will be thrown.

Tasks can only be added if the group is not already in the queue. Error will be thrown.

Parameters
task:ITask — New task to be added to group.
applyOverrides()method 
protected function applyOverrides(newTask:ITask):Boolean

Used to find and remove any tasks in the current group queue that are overriden by a new task that has been added to the group.

If the new task is selfOverriding two scenarios will play out.

Parameters
newTask:ITask — New Task to be added to queue

Returns
Boolean — Boolean True if newTasks overrides were processed,otherwise false
cancel()method 
public function cancel():void

Method is used to change groups phase to canel and dispath event. The phase is first changed and then all tasks in the group are canceled before cancel event is dispatched (TestEvent.TASK_CANCEL). Method should NOT be called by anyone but the TaskController.

getTaskIndex()method 
public function getTaskIndex(task:ITask):int

Returns the index of a task in the taskQueue. Tasks that have been proccessed will not be found. Check the phase of a task if you are sure a task is part of the group.

Parameters
task:ITask

Returns
int — 0 or greater if task is found, otherwise -1
handleTaskEvent()method 
protected function handleTaskEvent(event:TaskEvent):void

Method handles group tasks that have been completed, cancel or errored. If the no more tasks are in queue, a complete event is dispatched.

Parameters
event:TaskEvent
ignore()method 
public function ignore():void

Method is used to change groups phase to ignore and dispath event. Method should NOT be called by anyone but the TaskController.

inQueue()method 
public function inQueue():void

Method is used to change groups phase to queued and dispath event. Method should NOT be called by anyone but the TaskController.

inWaitingForReady()method 
public function inWaitingForReady():void

Method is used to change groups phase to wait for ready and dispath event. Method should NOT be called by anyone but the TaskController.

next()method 
public function next():ITask

Returns the next task in the group with the highest priority task first. This method removes the task from the task queue and addes to a proccessed queue.

Returns
ITask — The next task in the group.
pause()method 
public function pause():void

Method is used to change groups phase to pause and dispath event. Method should NOT be called by anyone but the TaskController.

removeAllTasks()method 
public function removeAllTasks():void

Removes all tasks from the group. When removed the task's cancel() method is called on all unproccessed tasks to allow listeners the ability to handle the removal. All proccessed tasks will simply be removed from the group. No further action is taken.

removeTask()method 
public function removeTask(task:ITask):void

Removes all instances of a specific task from the group. When removed the task's cancel() method is called to allow listeners the ability to handle the removal.

Parameters
task:ITask — The task to remove.
start()method 
public function start():void

Method is used to change groups phase to start and dispath event. Method should NOT be called by anyone but the TaskController.

Constant detail
GROUP_NOT_QUEUEDconstant
public static const GROUP_NOT_QUEUED:String = "GROUP_NOT_QUEUED"

The default phase value of a group when it is first constructed but not added to the TaskController.