| Package | com.developmentarc.framework.datastructures.tasks |
| Class | public class TaskGroup |
| Inheritance | TaskGroup flash.events.EventDispatcher |
| Implements | ITaskGroup |
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
| Property | Defined 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 | ||
| Property | Defined 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 | ||
| Method | Defined by | ||
|---|---|---|---|
|
TaskGroup(type:String, priority:int = 5, uid:Object = null, selfOverride:Boolean = false, blocking:Boolean = false)
Constructor.
| TaskGroup | ||
|
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 | ||
|
inWaitingForReady():void
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 | ||
|
removeAllTasks():void
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 | ||
| Method | Defined 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 | ||
|
handleTaskEvent(event:TaskEvent):void
Method handles group tasks that have been completed, cancel or errored.
| TaskGroup | ||
| Constant | Defined 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 | ||
| currentPhase | property |
protected var currentPhase:String = "GROUP_NOT_QUEUED"The current phase of the group.
| hasTask | property |
hasTask:Boolean [read-only]Determines if TaskGroup contains tasks or not.
Implementation public function get hasTask():Boolean
| isBlocker | property |
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
| phase | property |
phase:String [read-only]Returns the current phase of the TaskGroup, such as started, etc.
Implementation public function get phase():String
| priority | property |
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
| processedQueue | property |
protected var processedQueue:PriorityQueueThe tasks that have been started, cancelled, ignored or errored out.
| ready | property |
ready:Boolean [read-only]TaskGroups are always ready and will return true
Implementation public function get ready():Boolean
| selfOverride | property |
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
| taskOverrides | property |
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
| taskQueue | property |
protected var taskQueue:PriorityQueueThe current tasks that have been added to the Group but have not been started() yet.
| tasks | property |
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
| type | property |
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
| uid | property |
uid:Object [read-only]Id of the group instance. Used in applying self overrides.
Implementation public function get uid():Object
| 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.
Parameterstype: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) |
| 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.
Parameterstask: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.
newTask:ITask — New Task to be added to queue
|
Boolean — Boolean True if newTasks overrides were processed,otherwise false
|
| cancel | () | method |
public function cancel():voidMethod 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):intReturns 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.
Parameterstask:ITask |
int — 0 or greater if task is found, otherwise -1
|
| handleTaskEvent | () | method |
protected function handleTaskEvent(event:TaskEvent):voidMethod handles group tasks that have been completed, cancel or errored. If the no more tasks are in queue, a complete event is dispatched.
Parametersevent:TaskEvent |
| ignore | () | method |
public function ignore():voidMethod 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():voidMethod 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():voidMethod 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():ITaskReturns 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.
ReturnsITask —
The next task in the group.
|
| pause | () | method |
public function pause():voidMethod 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():voidRemoves 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):voidRemoves 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.
Parameterstask:ITask — The task to remove.
|
| start | () | method |
public function start():voidMethod is used to change groups phase to start and dispath event. Method should NOT be called by anyone but the TaskController.
| GROUP_NOT_QUEUED | constant |
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.