diff --git a/CHANGES.md b/CHANGES.md index c8f652a..27f38a6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,10 @@ -* **2013.01.31** - *v0.9.14* +* **2013.02.09** - *v0.9.15* + * Rewriting of some of the Task prototype property descriptors + +* **2013.02.07** - *v0.9.14* * Fixed an issue where unreferenced `tasks` attribute was not being instantiated for the `initialize` method with use of `addSubTask` * Fixed issue with tasks being processed in parallel task before the task had been started + * **2013.01.31** - *v0.9.13* * `onChange` is no longer a public method * Tasks now have events and can be referenced through `on`, `off`, `has` and `trigger` methods of the task diff --git a/docs/classes/MonkeyBars.html b/docs/classes/MonkeyBars.html index 0d4efdf..7ec4641 100644 --- a/docs/classes/MonkeyBars.html +++ b/docs/classes/MonkeyBars.html @@ -1143,7 +1143,7 @@

forTaskDecorator

- ../temp/monkeybars.js:1903 + ../temp/monkeybars.js:1952

@@ -1750,7 +1750,7 @@

whenTaskDecorator

- ../temp/monkeybars.js:1956 + ../temp/monkeybars.js:2005

@@ -1839,7 +1839,7 @@

whileTaskDecorator

- ../temp/monkeybars.js:1927 + ../temp/monkeybars.js:1976

@@ -1918,7 +1918,7 @@

LogLevels

- ../temp/monkeybars.js:2008 + ../temp/monkeybars.js:2057

@@ -2146,7 +2146,7 @@

TaskStates

- ../temp/monkeybars.js:1980 + ../temp/monkeybars.js:2029

@@ -2192,7 +2192,7 @@

TaskTypes

- ../temp/monkeybars.js:1995 + ../temp/monkeybars.js:2044

diff --git a/docs/classes/ParallelTask.html b/docs/classes/ParallelTask.html index c8954d8..74bf255 100644 --- a/docs/classes/ParallelTask.html +++ b/docs/classes/ParallelTask.html @@ -106,7 +106,7 @@

ParallelTask Class

- Defined in: ../temp/monkeybars.js:1565 + Defined in: ../temp/monkeybars.js:1607
@@ -167,7 +167,7 @@

ParallelTask

- ../temp/monkeybars.js:1565 + ../temp/monkeybars.js:1607

@@ -637,7 +637,7 @@

__onStateChange

- ../temp/monkeybars.js:856 + ../temp/monkeybars.js:859

@@ -740,7 +740,7 @@

addSubTask

- ../temp/monkeybars.js:1612 + ../temp/monkeybars.js:1654

@@ -832,7 +832,7 @@

addSubTaskAfterTask

- ../temp/monkeybars.js:1281 + ../temp/monkeybars.js:1295

@@ -950,7 +950,7 @@

addSubTaskBeforeTask

- ../temp/monkeybars.js:1312 + ../temp/monkeybars.js:1326

@@ -1043,7 +1043,7 @@

cancel

- ../temp/monkeybars.js:1338 + ../temp/monkeybars.js:1352

@@ -1101,7 +1101,7 @@

canProcessSubTask

- ../temp/monkeybars.js:1635 + ../temp/monkeybars.js:1677

@@ -1181,7 +1181,7 @@

complete

- ../temp/monkeybars.js:906 + ../temp/monkeybars.js:910

@@ -1284,7 +1284,7 @@

destroy

- ../temp/monkeybars.js:948 + ../temp/monkeybars.js:953

@@ -1345,7 +1345,7 @@

fault

- ../temp/monkeybars.js:980 + ../temp/monkeybars.js:985

@@ -1451,7 +1451,7 @@

getTaskByName

- ../temp/monkeybars.js:1364 + ../temp/monkeybars.js:1378

@@ -1552,7 +1552,7 @@

getTaskByTid

- ../temp/monkeybars.js:1382 + ../temp/monkeybars.js:1396

@@ -1759,7 +1759,7 @@

hasNoEnabledSubTasks

- ../temp/monkeybars.js:1678 + ../temp/monkeybars.js:1722

@@ -1833,7 +1833,7 @@

initialize

- ../temp/monkeybars.js:1015 + ../temp/monkeybars.js:1020

@@ -2159,7 +2159,7 @@

onCancel

- ../temp/monkeybars.js:1025 + ../temp/monkeybars.js:1031

@@ -2210,7 +2210,7 @@

onComplete

- ../temp/monkeybars.js:1034 + ../temp/monkeybars.js:1041

@@ -2271,7 +2271,7 @@

onFault

- ../temp/monkeybars.js:1043 + ../temp/monkeybars.js:1051

@@ -2345,7 +2345,7 @@

onStart

- ../temp/monkeybars.js:1053 + ../temp/monkeybars.js:1062

@@ -2406,7 +2406,7 @@

onSubTaskCancel

- ../temp/monkeybars.js:1405 + ../temp/monkeybars.js:1419

@@ -2494,7 +2494,7 @@

onSubTaskComplete

- ../temp/monkeybars.js:1699 + ../temp/monkeybars.js:1743

@@ -2586,7 +2586,7 @@

onSubTaskFault

- ../temp/monkeybars.js:1436 + ../temp/monkeybars.js:1452

@@ -2691,7 +2691,7 @@

operate

- ../temp/monkeybars.js:1062 + ../temp/monkeybars.js:1072

@@ -2783,7 +2783,7 @@

performTask

- ../temp/monkeybars.js:1717 + ../temp/monkeybars.js:1762

@@ -2849,7 +2849,7 @@

processSubTask

- ../temp/monkeybars.js:1734 + ../temp/monkeybars.js:1780

@@ -2929,7 +2929,7 @@

processSubTasks

- ../temp/monkeybars.js:1751 + ../temp/monkeybars.js:1797

@@ -2990,7 +2990,7 @@

removeSubTask

- ../temp/monkeybars.js:1500 + ../temp/monkeybars.js:1517

@@ -3068,7 +3068,7 @@

reset

- ../temp/monkeybars.js:1517 + ../temp/monkeybars.js:1534

@@ -3129,7 +3129,7 @@

setDependeciesForTask

- ../temp/monkeybars.js:1535 + ../temp/monkeybars.js:1552

@@ -3203,7 +3203,7 @@

start

- ../temp/monkeybars.js:1110 + ../temp/monkeybars.js:1122

@@ -3259,7 +3259,7 @@

state

- ../temp/monkeybars.js:1144 + ../temp/monkeybars.js:1157

@@ -3409,7 +3409,7 @@

_currentIndex

- ../temp/monkeybars.js:1213 + ../temp/monkeybars.js:1227

@@ -3452,7 +3452,7 @@

_dependencyMap

- ../temp/monkeybars.js:1202 + ../temp/monkeybars.js:1215

@@ -3538,7 +3538,7 @@

_processedIndex

- ../temp/monkeybars.js:1225 + ../temp/monkeybars.js:1239

@@ -3622,7 +3622,7 @@

concurrent

- ../temp/monkeybars.js:776 + ../temp/monkeybars.js:777

@@ -3665,7 +3665,7 @@

displayName

- ../temp/monkeybars.js:962 + ../temp/monkeybars.js:967

@@ -3706,7 +3706,7 @@

logLevel

- ../temp/monkeybars.js:787 + ../temp/monkeybars.js:789

@@ -3749,7 +3749,7 @@

timeout

- ../temp/monkeybars.js:799 + ../temp/monkeybars.js:801

@@ -3795,7 +3795,7 @@

type

- ../temp/monkeybars.js:1597 + ../temp/monkeybars.js:1639

@@ -3836,7 +3836,7 @@

worker

- ../temp/monkeybars.js:822 + ../temp/monkeybars.js:824

diff --git a/docs/classes/SequenceTask.html b/docs/classes/SequenceTask.html index 62067c1..0afacbb 100644 --- a/docs/classes/SequenceTask.html +++ b/docs/classes/SequenceTask.html @@ -106,7 +106,7 @@

SequenceTask Class

- Defined in: ../temp/monkeybars.js:1774 + Defined in: ../temp/monkeybars.js:1820
@@ -167,7 +167,7 @@

SequenceTask

- ../temp/monkeybars.js:1774 + ../temp/monkeybars.js:1820

@@ -623,7 +623,7 @@

__onStateChange

- ../temp/monkeybars.js:856 + ../temp/monkeybars.js:859

@@ -723,7 +723,7 @@

addSubTask

- ../temp/monkeybars.js:1245 + ../temp/monkeybars.js:1259

@@ -837,7 +837,7 @@

addSubTaskAfterTask

- ../temp/monkeybars.js:1281 + ../temp/monkeybars.js:1295

@@ -955,7 +955,7 @@

addSubTaskBeforeTask

- ../temp/monkeybars.js:1312 + ../temp/monkeybars.js:1326

@@ -1048,7 +1048,7 @@

cancel

- ../temp/monkeybars.js:1338 + ../temp/monkeybars.js:1352

@@ -1115,7 +1115,7 @@

complete

- ../temp/monkeybars.js:906 + ../temp/monkeybars.js:910

@@ -1218,7 +1218,7 @@

destroy

- ../temp/monkeybars.js:948 + ../temp/monkeybars.js:953

@@ -1279,7 +1279,7 @@

fault

- ../temp/monkeybars.js:980 + ../temp/monkeybars.js:985

@@ -1385,7 +1385,7 @@

getTaskByName

- ../temp/monkeybars.js:1364 + ../temp/monkeybars.js:1378

@@ -1486,7 +1486,7 @@

getTaskByTid

- ../temp/monkeybars.js:1382 + ../temp/monkeybars.js:1396

@@ -1696,7 +1696,7 @@

initialize

- ../temp/monkeybars.js:1015 + ../temp/monkeybars.js:1020

@@ -2022,7 +2022,7 @@

onCancel

- ../temp/monkeybars.js:1025 + ../temp/monkeybars.js:1031

@@ -2073,7 +2073,7 @@

onComplete

- ../temp/monkeybars.js:1034 + ../temp/monkeybars.js:1041

@@ -2134,7 +2134,7 @@

onFault

- ../temp/monkeybars.js:1043 + ../temp/monkeybars.js:1051

@@ -2208,7 +2208,7 @@

onStart

- ../temp/monkeybars.js:1053 + ../temp/monkeybars.js:1062

@@ -2272,7 +2272,7 @@

onSubTaskCancel

- ../temp/monkeybars.js:1821 + ../temp/monkeybars.js:1867

@@ -2360,7 +2360,7 @@

onSubTaskComplete

- ../temp/monkeybars.js:1837 + ../temp/monkeybars.js:1884

@@ -2451,7 +2451,7 @@

onSubTaskFault

- ../temp/monkeybars.js:1436 + ../temp/monkeybars.js:1452

@@ -2556,7 +2556,7 @@

operate

- ../temp/monkeybars.js:1062 + ../temp/monkeybars.js:1072

@@ -2658,7 +2658,7 @@

performTask

- ../temp/monkeybars.js:1858 + ../temp/monkeybars.js:1906

@@ -2743,7 +2743,7 @@

processSubTask

- ../temp/monkeybars.js:1449 + ../temp/monkeybars.js:1466

@@ -2830,7 +2830,7 @@

removeSubTask

- ../temp/monkeybars.js:1500 + ../temp/monkeybars.js:1517

@@ -2908,7 +2908,7 @@

reset

- ../temp/monkeybars.js:1517 + ../temp/monkeybars.js:1534

@@ -2969,7 +2969,7 @@

setDependeciesForTask

- ../temp/monkeybars.js:1535 + ../temp/monkeybars.js:1552

@@ -3043,7 +3043,7 @@

start

- ../temp/monkeybars.js:1110 + ../temp/monkeybars.js:1122

@@ -3098,7 +3098,7 @@

startNextSubTask

- ../temp/monkeybars.js:1871 + ../temp/monkeybars.js:1920

@@ -3153,7 +3153,7 @@

state

- ../temp/monkeybars.js:1144 + ../temp/monkeybars.js:1157

@@ -3303,7 +3303,7 @@

_currentIndex

- ../temp/monkeybars.js:1213 + ../temp/monkeybars.js:1227

@@ -3346,7 +3346,7 @@

_dependencyMap

- ../temp/monkeybars.js:1202 + ../temp/monkeybars.js:1215

@@ -3432,7 +3432,7 @@

_processedIndex

- ../temp/monkeybars.js:1225 + ../temp/monkeybars.js:1239

@@ -3516,7 +3516,7 @@

concurrent

- ../temp/monkeybars.js:776 + ../temp/monkeybars.js:777

@@ -3559,7 +3559,7 @@

displayName

- ../temp/monkeybars.js:962 + ../temp/monkeybars.js:967

@@ -3600,7 +3600,7 @@

logLevel

- ../temp/monkeybars.js:787 + ../temp/monkeybars.js:789

@@ -3643,7 +3643,7 @@

timeout

- ../temp/monkeybars.js:799 + ../temp/monkeybars.js:801

@@ -3689,7 +3689,7 @@

type

- ../temp/monkeybars.js:1806 + ../temp/monkeybars.js:1852

@@ -3730,7 +3730,7 @@

worker

- ../temp/monkeybars.js:822 + ../temp/monkeybars.js:824

diff --git a/docs/classes/Task.html b/docs/classes/Task.html index 4b4001e..0e3ced6 100644 --- a/docs/classes/Task.html +++ b/docs/classes/Task.html @@ -529,7 +529,7 @@

__onStateChange

- ../temp/monkeybars.js:856 + ../temp/monkeybars.js:859

@@ -622,7 +622,7 @@

cancel

- ../temp/monkeybars.js:873 + ../temp/monkeybars.js:877

@@ -709,7 +709,7 @@

complete

- ../temp/monkeybars.js:906 + ../temp/monkeybars.js:910

@@ -815,7 +815,7 @@

destroy

- ../temp/monkeybars.js:948 + ../temp/monkeybars.js:953

@@ -879,7 +879,7 @@

fault

- ../temp/monkeybars.js:980 + ../temp/monkeybars.js:985

@@ -1085,7 +1085,7 @@

initialize

- ../temp/monkeybars.js:1015 + ../temp/monkeybars.js:1020

@@ -1414,7 +1414,7 @@

onCancel

- ../temp/monkeybars.js:1025 + ../temp/monkeybars.js:1031

@@ -1468,7 +1468,7 @@

onComplete

- ../temp/monkeybars.js:1034 + ../temp/monkeybars.js:1041

@@ -1532,7 +1532,7 @@

onFault

- ../temp/monkeybars.js:1043 + ../temp/monkeybars.js:1051

@@ -1609,7 +1609,7 @@

onStart

- ../temp/monkeybars.js:1053 + ../temp/monkeybars.js:1062

@@ -1679,7 +1679,7 @@

operate

- ../temp/monkeybars.js:1062 + ../temp/monkeybars.js:1072

@@ -1771,7 +1771,7 @@

performTask

- ../temp/monkeybars.js:1074 + ../temp/monkeybars.js:1085

@@ -1844,7 +1844,7 @@

reset

- ../temp/monkeybars.js:1098 + ../temp/monkeybars.js:1110

@@ -1898,7 +1898,7 @@

start

- ../temp/monkeybars.js:1110 + ../temp/monkeybars.js:1122

@@ -1957,7 +1957,7 @@

state

- ../temp/monkeybars.js:1144 + ../temp/monkeybars.js:1157

@@ -2197,7 +2197,7 @@

concurrent

- ../temp/monkeybars.js:776 + ../temp/monkeybars.js:777

@@ -2243,7 +2243,7 @@

displayName

- ../temp/monkeybars.js:962 + ../temp/monkeybars.js:967

@@ -2287,7 +2287,7 @@

logLevel

- ../temp/monkeybars.js:787 + ../temp/monkeybars.js:789

@@ -2333,7 +2333,7 @@

timeout

- ../temp/monkeybars.js:799 + ../temp/monkeybars.js:801

@@ -2379,7 +2379,7 @@

type

- ../temp/monkeybars.js:811 + ../temp/monkeybars.js:813

@@ -2423,7 +2423,7 @@

worker

- ../temp/monkeybars.js:822 + ../temp/monkeybars.js:824

diff --git a/docs/classes/TaskGroup.html b/docs/classes/TaskGroup.html index 46c8f4f..fc71600 100644 --- a/docs/classes/TaskGroup.html +++ b/docs/classes/TaskGroup.html @@ -106,7 +106,7 @@

TaskGroup Class

- Defined in: ../temp/monkeybars.js:1164 + Defined in: ../temp/monkeybars.js:1177
@@ -167,7 +167,7 @@

TaskGroup

- ../temp/monkeybars.js:1164 + ../temp/monkeybars.js:1177

@@ -596,7 +596,7 @@

__onStateChange

- ../temp/monkeybars.js:856 + ../temp/monkeybars.js:859

@@ -699,7 +699,7 @@

addSubTask

- ../temp/monkeybars.js:1245 + ../temp/monkeybars.js:1259

@@ -816,7 +816,7 @@

addSubTaskAfterTask

- ../temp/monkeybars.js:1281 + ../temp/monkeybars.js:1295

@@ -937,7 +937,7 @@

addSubTaskBeforeTask

- ../temp/monkeybars.js:1312 + ../temp/monkeybars.js:1326

@@ -1030,7 +1030,7 @@

cancel

- ../temp/monkeybars.js:1338 + ../temp/monkeybars.js:1352

@@ -1097,7 +1097,7 @@

complete

- ../temp/monkeybars.js:906 + ../temp/monkeybars.js:910

@@ -1200,7 +1200,7 @@

destroy

- ../temp/monkeybars.js:948 + ../temp/monkeybars.js:953

@@ -1261,7 +1261,7 @@

fault

- ../temp/monkeybars.js:980 + ../temp/monkeybars.js:985

@@ -1370,7 +1370,7 @@

getTaskByName

- ../temp/monkeybars.js:1364 + ../temp/monkeybars.js:1378

@@ -1474,7 +1474,7 @@

getTaskByTid

- ../temp/monkeybars.js:1382 + ../temp/monkeybars.js:1396

@@ -1684,7 +1684,7 @@

initialize

- ../temp/monkeybars.js:1015 + ../temp/monkeybars.js:1020

@@ -2010,7 +2010,7 @@

onCancel

- ../temp/monkeybars.js:1025 + ../temp/monkeybars.js:1031

@@ -2061,7 +2061,7 @@

onComplete

- ../temp/monkeybars.js:1034 + ../temp/monkeybars.js:1041

@@ -2122,7 +2122,7 @@

onFault

- ../temp/monkeybars.js:1043 + ../temp/monkeybars.js:1051

@@ -2196,7 +2196,7 @@

onStart

- ../temp/monkeybars.js:1053 + ../temp/monkeybars.js:1062

@@ -2260,7 +2260,7 @@

onSubTaskCancel

- ../temp/monkeybars.js:1405 + ../temp/monkeybars.js:1419

@@ -2348,7 +2348,7 @@

onSubTaskComplete

- ../temp/monkeybars.js:1423 + ../temp/monkeybars.js:1438

@@ -2442,7 +2442,7 @@

onSubTaskFault

- ../temp/monkeybars.js:1436 + ../temp/monkeybars.js:1452

@@ -2547,7 +2547,7 @@

operate

- ../temp/monkeybars.js:1062 + ../temp/monkeybars.js:1072

@@ -2636,7 +2636,7 @@

performTask

- ../temp/monkeybars.js:1074 + ../temp/monkeybars.js:1085

@@ -2719,7 +2719,7 @@

processSubTask

- ../temp/monkeybars.js:1449 + ../temp/monkeybars.js:1466

@@ -2809,7 +2809,7 @@

removeSubTask

- ../temp/monkeybars.js:1500 + ../temp/monkeybars.js:1517

@@ -2887,7 +2887,7 @@

reset

- ../temp/monkeybars.js:1517 + ../temp/monkeybars.js:1534

@@ -2951,7 +2951,7 @@

setDependeciesForTask

- ../temp/monkeybars.js:1535 + ../temp/monkeybars.js:1552

@@ -3025,7 +3025,7 @@

start

- ../temp/monkeybars.js:1110 + ../temp/monkeybars.js:1122

@@ -3081,7 +3081,7 @@

state

- ../temp/monkeybars.js:1144 + ../temp/monkeybars.js:1157

@@ -3234,7 +3234,7 @@

_currentIndex

- ../temp/monkeybars.js:1213 + ../temp/monkeybars.js:1227

@@ -3280,7 +3280,7 @@

_dependencyMap

- ../temp/monkeybars.js:1202 + ../temp/monkeybars.js:1215

@@ -3369,7 +3369,7 @@

_processedIndex

- ../temp/monkeybars.js:1225 + ../temp/monkeybars.js:1239

@@ -3453,7 +3453,7 @@

concurrent

- ../temp/monkeybars.js:776 + ../temp/monkeybars.js:777

@@ -3496,7 +3496,7 @@

displayName

- ../temp/monkeybars.js:962 + ../temp/monkeybars.js:967

@@ -3537,7 +3537,7 @@

logLevel

- ../temp/monkeybars.js:787 + ../temp/monkeybars.js:789

@@ -3580,7 +3580,7 @@

timeout

- ../temp/monkeybars.js:799 + ../temp/monkeybars.js:801

@@ -3623,7 +3623,7 @@

type

- ../temp/monkeybars.js:811 + ../temp/monkeybars.js:813

@@ -3664,7 +3664,7 @@

worker

- ../temp/monkeybars.js:822 + ../temp/monkeybars.js:824

diff --git a/docs/data.json b/docs/data.json index a822901..5170a1a 100644 --- a/docs/data.json +++ b/docs/data.json @@ -110,7 +110,7 @@ "plugin_for": [], "extension_for": [], "file": "../temp/monkeybars.js", - "line": 1164, + "line": 1177, "description": "A task group, and extention of task, provides the building blocks for creating\na group of tasks that is inherently a task itself.", "extends": "Task", "is_constructor": 1, @@ -131,7 +131,7 @@ "plugin_for": [], "extension_for": [], "file": "../temp/monkeybars.js", - "line": 1565, + "line": 1607, "description": "A ParallelTask is a TaskGroup that runs all of its subtasks ansynchronously. Its\ncomplete functionality is run when all of its sub tasks are complete.", "extends": "TaskGroup", "is_constructor": 1, @@ -155,7 +155,7 @@ "plugin_for": [], "extension_for": [], "file": "../temp/monkeybars.js", - "line": 1774, + "line": 1820, "description": "A SequenceTask is a TaskGroup that runs all of its subtasks serially. Its\ncomplete functionality is run when all of its sub tasks are complete.", "extends": "TaskGroup", "is_constructor": 1, @@ -656,7 +656,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 776, + "line": 777, "description": "Whether or not to run the task concurrently through Web Workers", "itemtype": "property", "name": "concurrent", @@ -666,7 +666,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 787, + "line": 789, "description": "The default logging level for tasks", "itemtype": "property", "name": "logLevel", @@ -676,7 +676,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 799, + "line": 801, "description": "Time in milliseconds in which a task will time out and throw a fault", "itemtype": "property", "name": "timeout", @@ -686,7 +686,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 811, + "line": 813, "description": "The kind of task", "itemtype": "property", "name": "type", @@ -696,7 +696,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 822, + "line": 824, "description": "This object can either be simply a reference to a custom WorkerTask extention's\nconstructor. Or it can be an object with a constructor key/value pair. If it is the\nlatter then you also have the option of passing a handler function that will be run\non the `onMessage` handler of the Worker itself.", "itemtype": "property", "name": "worker", @@ -709,7 +709,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 856, + "line": 859, "description": "This method is called during the execution lifecycle of the task. It is intentionally\nleft blank and is up to the instance to describe it functionality.", "itemtype": "method", "name": "__onStateChange", @@ -731,7 +731,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 873, + "line": 877, "description": "Calling this method cancels the task. However it is up to the instance to handle\nthe canceled state.", "itemtype": "method", "name": "cancel", @@ -742,7 +742,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 906, + "line": 910, "description": "Calling this method says that the tasks execution is now complete.", "itemtype": "method", "name": "complete", @@ -765,14 +765,14 @@ }, { "file": "../temp/monkeybars.js", - "line": 948, + "line": 953, "itemtype": "method", "name": "destroy", "class": "Task" }, { "file": "../temp/monkeybars.js", - "line": 962, + "line": 967, "description": "Display name for task. Used in logging output.", "itemtype": "property", "name": "displayName", @@ -786,7 +786,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 980, + "line": 985, "description": "Calling this method to fault a task. If it is part of a group task this will\nalso call the groups fault method passing the error up to the group.", "itemtype": "method", "name": "fault", @@ -804,7 +804,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1015, + "line": 1020, "description": "Initialization functionality", "itemtype": "method", "name": "initialize", @@ -819,7 +819,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1025, + "line": 1031, "description": "Convenience method called when the task is canceled.", "itemtype": "method", "name": "onCancel", @@ -827,7 +827,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1034, + "line": 1041, "description": "Convenience method called when the task completes.", "itemtype": "method", "name": "onComplete", @@ -835,7 +835,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1043, + "line": 1051, "description": "Convenience method called when the task faults.", "itemtype": "method", "name": "onFault", @@ -850,7 +850,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1053, + "line": 1062, "description": "Convenience method called when the task starts.", "itemtype": "method", "name": "onStart", @@ -858,7 +858,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1062, + "line": 1072, "itemtype": "method", "name": "operate", "params": [ @@ -877,7 +877,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1074, + "line": 1085, "description": "This method is required for **simple** tasks and will throw an exception if it\nis called and not overridden. If you overwrite this method on a task group\nthen you need to make sure that you call the extended/implemented classes\noriginal prototype method (see the example below).", "itemtype": "method", "name": "performTask", @@ -889,7 +889,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1098, + "line": 1110, "description": "Resets a task to its original state", "itemtype": "method", "name": "reset", @@ -897,7 +897,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1110, + "line": 1122, "description": "Kicks off the execution of the task by calling the tasks `performTask` method.\nThis method can only be run once on a task.", "itemtype": "method", "name": "start", @@ -905,7 +905,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1144, + "line": 1157, "description": "Getter for the tasks current state. Code outside of an implementation should not set the \nstate as this is an internal property.", "itemtype": "method", "name": "state", @@ -917,7 +917,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1202, + "line": 1215, "description": "Holds all references to event types, callbacks, contexts and configurations.", "itemtype": "property", "name": "_dependencyMap", @@ -928,7 +928,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1213, + "line": 1227, "description": "The index of the subtasks that have completed execution.", "itemtype": "property", "name": "_currentIndex", @@ -939,7 +939,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1225, + "line": 1239, "description": "An incrimented number of the tasks that have already been processed.", "itemtype": "property", "name": "_processedIndex", @@ -950,7 +950,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1245, + "line": 1259, "description": "Adds a subtask to the groups queue. This is helpful when you want to add\na sub task after instantiation.", "itemtype": "method", "name": "addSubTask", @@ -968,7 +968,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1281, + "line": 1295, "description": "Adds a subtask after another task", "itemtype": "method", "name": "addSubTaskAfterTask", @@ -991,7 +991,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1312, + "line": 1326, "description": "Very similar to `addSubTaskAfterTask` except the inject task appears\nbefore the second arguments position.", "itemtype": "method", "name": "addSubTaskBeforeTask", @@ -1011,7 +1011,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1338, + "line": 1352, "description": "Cancel the group and cancel all of its subtasks", "itemtype": "method", "name": "cancel", @@ -1019,7 +1019,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1364, + "line": 1378, "description": "Return a Task object, if it exists, based on the `name` passed.", "itemtype": "method", "name": "getTaskByName", @@ -1038,7 +1038,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1382, + "line": 1396, "description": "Return a Task object, if it exists, based on the `tid` passed.", "itemtype": "method", "name": "getTaskByTid", @@ -1060,7 +1060,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1405, + "line": 1419, "description": "Called when a subtask calls its cancel method. When a subtask is canceled\nany other subtasks that are dependent on the canceled task are cancled.", "itemtype": "method", "name": "onSubTaskCancel", @@ -1075,7 +1075,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1423, + "line": 1438, "description": "Called when a sub task completes. Must be overridden with functionality\nprovided by the extending class.", "itemtype": "method", "name": "onSubTaskComplete", @@ -1090,7 +1090,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1436, + "line": 1452, "description": "Called when a subtask calls its fault method.", "itemtype": "method", "name": "onSubTaskFault", @@ -1110,7 +1110,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1449, + "line": 1466, "description": "Processes a sub task and prepares it for execution. This method overwrites the\ntasks on change functionality. If you wish to have a sub task that handles\nits own change functionality then you will need to implement the partner\nconvenience methods.", "itemtype": "method", "name": "processSubTask", @@ -1125,7 +1125,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1500, + "line": 1517, "description": "Removes a task from its group. Removing the task after it has executed will\nhave no apparent affect as it has already ran.", "itemtype": "method", "name": "removeSubTask", @@ -1140,7 +1140,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1517, + "line": 1534, "description": "Resets a task to its original state", "itemtype": "method", "name": "reset", @@ -1148,7 +1148,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1535, + "line": 1552, "description": "Sets dependencies for the passed task.", "itemtype": "method", "name": "setDependeciesForTask", @@ -1163,7 +1163,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1597, + "line": 1639, "description": "The kind of task", "itemtype": "property", "name": "type", @@ -1173,7 +1173,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1612, + "line": 1654, "description": "This method is overridden from `TaskGroups` implementation because of the\nnature of a parallel task. When a task is added it should be immediately\nprocessed and started.", "itemtype": "method", "name": "addSubTask", @@ -1188,7 +1188,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1635, + "line": 1677, "itemtype": "method", "name": "canProcessSubTask", "return": { @@ -1199,7 +1199,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1678, + "line": 1722, "description": "Checks whether or not the group has any enabled sub tasks.", "itemtype": "method", "name": "hasNoEnabledSubTasks", @@ -1211,7 +1211,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1699, + "line": 1743, "description": "Overridden from TaskGroup. This method is run everytime a sub task\ncompletes. When all subtasks are complete the groups complete method\nis called.", "itemtype": "method", "name": "onSubTaskComplete", @@ -1226,7 +1226,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1717, + "line": 1762, "description": "Overridden from Task. First checks to see if there are any enabled\nsubtasks to process. If there arent the groups complete method is called.\nIf there are then the group processes all of the sub tasks it has.", "itemtype": "method", "name": "performTask", @@ -1234,7 +1234,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1734, + "line": 1780, "description": "Overridden from TaskGroup. Processes a sub task and prepares it for execution. This method overwrites the\ntasks on change functionality. If you wish to have a sub task that handles\nits own change functionality then you will need to implement the partner\nconvenience methods.", "itemtype": "method", "name": "processSubTask", @@ -1249,7 +1249,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1751, + "line": 1797, "description": "Processes all of the sub tasks available for the group", "itemtype": "method", "name": "processSubTasks", @@ -1257,7 +1257,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1806, + "line": 1852, "description": "The kind of task", "itemtype": "property", "name": "type", @@ -1267,7 +1267,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1821, + "line": 1867, "description": "Overriden from TaskGroup. As long as the group has not been canceled,\nwhen a sub task is canceled it simply moves on to the next task in the queue.", "itemtype": "method", "name": "onSubTaskCancel", @@ -1282,7 +1282,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1837, + "line": 1884, "description": "Overridden from TaskGroup. As long as the group has not been canceled,\nwhen a sub task completes it starts the next sibling in the queue.", "itemtype": "method", "name": "onSubTaskComplete", @@ -1297,7 +1297,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1858, + "line": 1906, "description": "Starts the next sub task in the sequence. If overriden you need to call the\nSequenceTask's prototype `performTask` method.", "itemtype": "method", "name": "performTask", @@ -1312,7 +1312,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1871, + "line": 1920, "description": "Starts the next task in the queue after its previous sibling has completed.", "itemtype": "method", "name": "startNextSubTask", @@ -1320,7 +1320,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1903, + "line": 1952, "description": "Decorator to provide for loop functionality for the task. The task executes\nas many times as referenced by the count attribute provided by the instance.", "itemtype": "method", "name": "forTaskDecorator", @@ -1337,7 +1337,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1927, + "line": 1976, "description": "Decorator to provide while loop functionaliy. The task executed until the `while`\nmethod returns false.", "itemtype": "method", "name": "whileTaskDecorator", @@ -1354,7 +1354,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1956, + "line": 2005, "description": "The task doesnt execute until the when method provided returns true.", "itemtype": "method", "name": "whenTaskDecorator", @@ -1371,7 +1371,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1980, + "line": 2029, "description": "Task states contstants.", "itemtype": "property", "name": "TaskStates", @@ -1381,7 +1381,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 1995, + "line": 2044, "description": "Task types contstants.", "itemtype": "property", "name": "TaskTypes", @@ -1391,7 +1391,7 @@ }, { "file": "../temp/monkeybars.js", - "line": 2008, + "line": 2057, "description": "Log level contstants.", "itemtype": "property", "name": "LogLevels", @@ -1407,7 +1407,7 @@ }, { "message": "replacing incorrect tag: function with method", - "line": " ../temp/monkeybars.js:948" + "line": " ../temp/monkeybars.js:953" }, { "message": "Missing item type", diff --git a/docs/files/.._temp_monkeybars.js.html b/docs/files/.._temp_monkeybars.js.html index d4eb0d0..6edffcb 100644 --- a/docs/files/.._temp_monkeybars.js.html +++ b/docs/files/.._temp_monkeybars.js.html @@ -866,7 +866,8 @@

File: ../temp/monkeybars.js

* @private */ _state: { - value: STATE_INITIALIZED + value: STATE_INITIALIZED, + writable: true }, // =================================================================== @@ -881,7 +882,8 @@

File: ../temp/monkeybars.js

* @default false */ concurrent: { - value: false + value: false, + writable: true }, /** @@ -946,7 +948,8 @@

File: ../temp/monkeybars.js

* }); */ worker: { - value: undefined + value: undefined, + writable: true }, // =================================================================== @@ -963,7 +966,8 @@

File: ../temp/monkeybars.js

* @private */ __onStateChange: { - value: function(state, error) {} + value: function(state, error) {}, + writable: true }, // =================================================================== @@ -1042,7 +1046,8 @@

File: ../temp/monkeybars.js

this.trigger("complete"); this.onComplete(); this.__onStateChange(this._state); - } + }, + writable: true }, /** @@ -1119,7 +1124,8 @@

File: ../temp/monkeybars.js

* @param {Object} attributes */ initialize: { - value: function(attributes) {} + value: function(attributes) {}, + writable: true }, /** @@ -1128,7 +1134,8 @@

File: ../temp/monkeybars.js

* @method onCancel */ onCancel: { - value: function() {} + value: function() {}, + writable: true }, /** @@ -1137,7 +1144,8 @@

File: ../temp/monkeybars.js

* @method onComplete */ onComplete: { - value: function() {} + value: function() {}, + writable: true }, /** @@ -1147,7 +1155,8 @@

File: ../temp/monkeybars.js

* @param {String} error Message describing error */ onFault: { - value: function(error) {} + value: function(error) {}, + writable: true }, /** @@ -1156,7 +1165,8 @@

File: ../temp/monkeybars.js

* @method onStart */ onStart: { - value: function() {} + value: function() {}, + writable: true }, /** @@ -1168,7 +1178,8 @@

File: ../temp/monkeybars.js

operate: { value: function(data, task) { this.data = data; - } + }, + writable: true }, /** @@ -1192,7 +1203,8 @@

File: ../temp/monkeybars.js

performTask: { value: function() { throw "performTask: " + OVERRIDE_NEEDED; - } + }, + writable: true }, /** @@ -1238,7 +1250,8 @@

File: ../temp/monkeybars.js

} this.onStart(); - } + }, + writable: true }, /** @@ -1307,7 +1320,8 @@

File: ../temp/monkeybars.js

* @private */ _dependencyMap: { - value: {} + value: {}, + writable: true }, /** @@ -1517,7 +1531,8 @@

File: ../temp/monkeybars.js

this.tasks[i]._state = STATE_CANCELED; } } - } + }, + writable: true }, /** @@ -1530,7 +1545,8 @@

File: ../temp/monkeybars.js

onSubTaskComplete: { value: function(task) { task.group.operate(task.data, task); - } + }, + writable: true }, /** @@ -1543,7 +1559,8 @@

File: ../temp/monkeybars.js

onSubTaskFault: { value: function(task, error) { this.fault(error); - } + }, + writable: true }, /** @@ -1644,6 +1661,20 @@

File: ../temp/monkeybars.js

var totalDependencies = task.dependencies.length; for (var i = 0; i < totalDependencies; i++) { var dependency = task.dependencies[i]; + + // if the depoendency is not an actual task then we need to find that + // task and reassign the dependency with the instance + if (dependency.tid === undefined) { + var t = this.getTaskByTid(dependency); + if (t === undefined) { + t = this.getTaskByName(dependency); + } + if (t !== undefined) { + dependency = task.dependencies[i] = t; + } + } + + // set the dependency to the groups dependency map if (dependency.tid) { this._dependencyMap[task.tid].push(dependency.tid); } else { @@ -1662,6 +1693,17 @@

File: ../temp/monkeybars.js

// === Parallel Task ================================================= // =================================================================== + /* + + @TODO: going to have to work on the processing flow to do the following: + + 1. start is called on group + 2. process all sub tasks + 3. performTask + 4. start all sub tasks that can be started + +*/ + /** * A ParallelTask is a TaskGroup that runs all of its subtasks ansynchronously. Its * complete functionality is run when all of its sub tasks are complete. @@ -1767,6 +1809,8 @@

File: ../temp/monkeybars.js

}; for (var j = 0; j < dependencies.length; j++) { var t = dependencies[j]; + console.log("add event"); + console.log(t); t.on("complete", completion, this, false); } return false; @@ -1811,7 +1855,8 @@

File: ../temp/monkeybars.js

if (this._currentIndex === this.tasks.length) { this.complete(); } - } + }, + writable: true }, /** @@ -1828,7 +1873,8 @@

File: ../temp/monkeybars.js

} else { this.processSubTasks(); } - } + }, + writable: true }, /** @@ -1931,7 +1977,8 @@

File: ../temp/monkeybars.js

if (this._state !== STATE_CANCELED) { this.startNextSubTask(); } - } + }, + writable: true }, /** @@ -1952,7 +1999,8 @@

File: ../temp/monkeybars.js

TaskGroup.prototype.onSubTaskComplete.call(this, task); delegate.startNextSubTask(); }, 0); - } + }, + writable: true }, /** @@ -1965,7 +2013,8 @@

File: ../temp/monkeybars.js

performTask: { value: function() { this.startNextSubTask(); - } + }, + writable: true }, /** diff --git a/examples/requirejs/group_task.js b/examples/requirejs/group_task.js new file mode 100644 index 0000000..e9fffe9 --- /dev/null +++ b/examples/requirejs/group_task.js @@ -0,0 +1,21 @@ +define(["monkeybars", "task1", "task2", "task3"], function( +MonkeyBars, Task1, Task2, Task3) { + + 'use strict'; + + var t1 = new Task1(); + var t2 = new Task2(); + var t3 = new Task3(); + + return MonkeyBars.ParallelTask.extend({ + name: "group", + tasks: [t1, t2, t3], + operate: function(data) { + if(this.data === undefined) { + this.data = []; + } + this.data.push(data); + } + }); + +}); \ No newline at end of file diff --git a/examples/requirejs/main.js b/examples/requirejs/main.js index 4ddad9a..dafe946 100644 --- a/examples/requirejs/main.js +++ b/examples/requirejs/main.js @@ -1,28 +1,28 @@ // requirejs config require.config({ - deps: ["main"], - paths: { - monkeybars: "../../monkeybars.min", - }, - shim: { - monkeybars: { - exports: "MonkeyBars" + deps: ["main"], + paths: { + monkeybars: "../../monkeybars", + }, + shim: { + monkeybars: { + exports: "MonkeyBars" + } } - } }); // main require -require(["monkeybars"], function(MonkeyBars) { +require(["group_task"], function(GroupTask) { - 'use strict'; + 'use strict'; - var task = new MonkeyBars.Task({ - logLevel:1000, - performTask:function(){ - this.complete(); - } - }); + var groupTask = new GroupTask({ + logLevel:1000, + onComplete: function() { + console.log(this.data); // should equal ["task1","task2","task3"] after 1 second timeout + } + }); - task.start(); + groupTask.start(); }); \ No newline at end of file diff --git a/examples/requirejs/task1.js b/examples/requirejs/task1.js new file mode 100644 index 0000000..060dff0 --- /dev/null +++ b/examples/requirejs/task1.js @@ -0,0 +1,15 @@ +define(["monkeybars"], function(MonkeyBars) { + + 'use strict'; + + return MonkeyBars.Task.extend({ + name: "task1", + performTask: function() { + var delegate = this; + setTimeout(function(){ + delegate.complete(delegate.displayName); + },1000); + } + }); + +}); \ No newline at end of file diff --git a/examples/requirejs/task2.js b/examples/requirejs/task2.js new file mode 100644 index 0000000..729a224 --- /dev/null +++ b/examples/requirejs/task2.js @@ -0,0 +1,12 @@ +define(["monkeybars"], function(MonkeyBars) { + + 'use strict'; + + return MonkeyBars.Task.extend({ + name: "task2", + performTask: function() { + this.complete(this.displayName); + } + }); + +}); \ No newline at end of file diff --git a/examples/requirejs/task3.js b/examples/requirejs/task3.js new file mode 100644 index 0000000..61ab92d --- /dev/null +++ b/examples/requirejs/task3.js @@ -0,0 +1,12 @@ +define(["monkeybars"], function(MonkeyBars) { + + 'use strict'; + + return MonkeyBars.Task.extend({ + name: "task3", + performTask: function() { + this.complete(this.displayName); + } + }); + +}); \ No newline at end of file diff --git a/monkeybars.js b/monkeybars.js index 0b9568c..767eb8e 100644 --- a/monkeybars.js +++ b/monkeybars.js @@ -766,7 +766,8 @@ * @private */ _state: { - value: STATE_INITIALIZED + value: STATE_INITIALIZED, + writable: true }, // =================================================================== @@ -781,7 +782,8 @@ * @default false */ concurrent: { - value: false + value: false, + writable: true }, /** @@ -846,7 +848,8 @@ * }); */ worker: { - value: undefined + value: undefined, + writable: true }, // =================================================================== @@ -863,7 +866,8 @@ * @private */ __onStateChange: { - value: function(state, error) {} + value: function(state, error) {}, + writable: true }, // =================================================================== @@ -942,7 +946,8 @@ this.trigger("complete"); this.onComplete(); this.__onStateChange(this._state); - } + }, + writable: true }, /** @@ -1019,7 +1024,8 @@ * @param {Object} attributes */ initialize: { - value: function(attributes) {} + value: function(attributes) {}, + writable: true }, /** @@ -1028,7 +1034,8 @@ * @method onCancel */ onCancel: { - value: function() {} + value: function() {}, + writable: true }, /** @@ -1037,7 +1044,8 @@ * @method onComplete */ onComplete: { - value: function() {} + value: function() {}, + writable: true }, /** @@ -1047,7 +1055,8 @@ * @param {String} error Message describing error */ onFault: { - value: function(error) {} + value: function(error) {}, + writable: true }, /** @@ -1056,7 +1065,8 @@ * @method onStart */ onStart: { - value: function() {} + value: function() {}, + writable: true }, /** @@ -1068,7 +1078,8 @@ operate: { value: function(data, task) { this.data = data; - } + }, + writable: true }, /** @@ -1092,7 +1103,8 @@ performTask: { value: function() { throw "performTask: " + OVERRIDE_NEEDED; - } + }, + writable: true }, /** @@ -1138,7 +1150,8 @@ } this.onStart(); - } + }, + writable: true }, /** @@ -1207,7 +1220,8 @@ * @private */ _dependencyMap: { - value: {} + value: {}, + writable: true }, /** @@ -1417,7 +1431,8 @@ this.tasks[i]._state = STATE_CANCELED; } } - } + }, + writable: true }, /** @@ -1430,7 +1445,8 @@ onSubTaskComplete: { value: function(task) { task.group.operate(task.data, task); - } + }, + writable: true }, /** @@ -1443,7 +1459,8 @@ onSubTaskFault: { value: function(task, error) { this.fault(error); - } + }, + writable: true }, /** @@ -1544,6 +1561,20 @@ var totalDependencies = task.dependencies.length; for (var i = 0; i < totalDependencies; i++) { var dependency = task.dependencies[i]; + + // if the depoendency is not an actual task then we need to find that + // task and reassign the dependency with the instance + if (dependency.tid === undefined) { + var t = this.getTaskByTid(dependency); + if (t === undefined) { + t = this.getTaskByName(dependency); + } + if (t !== undefined) { + dependency = task.dependencies[i] = t; + } + } + + // set the dependency to the groups dependency map if (dependency.tid) { this._dependencyMap[task.tid].push(dependency.tid); } else { @@ -1562,6 +1593,17 @@ // === Parallel Task ================================================= // =================================================================== + /* + + @TODO: going to have to work on the processing flow to do the following: + + 1. start is called on group + 2. process all sub tasks + 3. performTask + 4. start all sub tasks that can be started + +*/ + /** * A ParallelTask is a TaskGroup that runs all of its subtasks ansynchronously. Its * complete functionality is run when all of its sub tasks are complete. @@ -1667,6 +1709,8 @@ }; for (var j = 0; j < dependencies.length; j++) { var t = dependencies[j]; + console.log("add event"); + console.log(t); t.on("complete", completion, this, false); } return false; @@ -1711,7 +1755,8 @@ if (this._currentIndex === this.tasks.length) { this.complete(); } - } + }, + writable: true }, /** @@ -1728,7 +1773,8 @@ } else { this.processSubTasks(); } - } + }, + writable: true }, /** @@ -1831,7 +1877,8 @@ if (this._state !== STATE_CANCELED) { this.startNextSubTask(); } - } + }, + writable: true }, /** @@ -1852,7 +1899,8 @@ TaskGroup.prototype.onSubTaskComplete.call(this, task); delegate.startNextSubTask(); }, 0); - } + }, + writable: true }, /** @@ -1865,7 +1913,8 @@ performTask: { value: function() { this.startNextSubTask(); - } + }, + writable: true }, /** diff --git a/monkeybars.min.js b/monkeybars.min.js index 7430fc4..2aaa13a 100644 --- a/monkeybars.min.js +++ b/monkeybars.min.js @@ -3,4 +3,4 @@ * http://mcgaryes.github.com/monkeybars/ * MonkeyBars may be freely distributed under the MIT license. */ -(function(){"use strict";var e=0,t=1,n=2,r=3,i=4,s="parallel",o="sequence",u="simple",a=0,f=10,l=20,c=30,h="task",p=100,d="Override Needed",v="Undefined Task",m="No Attributes",g="Unknown Task Type",y="Invalid Arguments",b="Unhandled 'postMessage'",w=this,E=0,S=["name","tid","data","type","concurrent","worker","displayName","state","logLevel","timeout","dependencies","group","processed","tasks","max","count","interval"],x=w.MonkeyBars={};typeof exports!="undefined"&&typeof module!="undefined"&&module.exports&&(exports=module.exports=x);var T=function(e){if(!e){e.logLevel>=f&&H(m);return}var t;if(e.tid)t=e;else{var n=e.type,r=e.tasks;r&&(e.tasks=N(r));if(n)if(n===u)t=new F(e);else if(n===o)t=new R(e);else{if(n!==s)throw g;t=new q(e)}else r?t=new R(e):t=new F(e)}return t},N=function(e){var t=[];if(e)for(var n=0;nf&&H(b+": "+A(e.data))},r.onerror=function(e){t.fault("WebWorker error.")},r},_=function(e){if(typeof Worker=="undefined"||typeof Blob=="undefined"||e.type!==u){e.performTask();return}var t=M(O(e),e);t.postMessage()},D=function(e,t){e.count&&U(e),e.when&&W(e),e.doWhile&&z(e)},P=function(e){var t=this,n=function(){t.apply(this,arguments)},r=C(e);return n.prototype=Object.create(t.prototype,r),n},H=function(e){console&&console.log&&console.log(e)},B={_eventMap:undefined,has:function(e){return this._eventMap===undefined||this._eventMap[e]===undefined?!1:!0},off:function(e,t){if(this._eventMap===undefined||this._eventMap[e]===undefined)return;if(e)if(t){var n=[];for(var r=0;rt)return;this._state=n,this.logLevel>=l&&H("Canceled: "+this.displayName),this.timeoutId&&clearTimeout(this.timeoutId),this.trigger("cancel"),this.__onStateChange(this._state),this.onCancel()}},complete:{value:function(e){if(this._state>t)return;this._state=i,this.logLevel>=l&&H("Completed: "+this.displayName),this.timeoutId&&clearTimeout(this.timeoutId),arguments.length!==0&&this.operate(e,this),this.trigger("complete"),this.onComplete(),this.__onStateChange(this._state)}},destroy:{value:function(){for(var e in this)this.hasOwnProperty(e)&&delete this[e]}},displayName:{get:function(){return this.name?this.name:this.type+":"+this.tid}},fault:{value:function(e){if(this._state>=n)return;this._state=r,this.logLevel>=l&&H("Faulted: "+this.displayName),this.timeoutId&&clearTimeout(this.timeoutId),this.trigger("fault"),this.__onStateChange(this._state,e),this.onFault(e)}},initialize:{value:function(e){}},onCancel:{value:function(){}},onComplete:{value:function(){}},onFault:{value:function(e){}},onStart:{value:function(){}},operate:{value:function(e,t){this.data=e}},performTask:{value:function(){throw"performTask: "+d}},reset:{value:function(){this._state=e,this.processed=!1}},start:{value:function(){if(this._state>=t)return;this._state=t,this.logLevel>=l&&H("Started: "+this.displayName);if(this.timeout!==undefined){var e=this;this.timeoutId=setTimeout(function(){e.fault()},this.timeout)}this.trigger("start"),this.__onStateChange(this._state),this.concurrent?_(this):this.performTask(),this.onStart()}},state:{get:function(){return this._state}}}),F.extend=P;var I=x.TaskGroup=function(e){var t=this;e&&e.tasks&&(t.tasks=N(e.tasks));if(t.tasks)for(var n=0;ne?r.cancel():r._state=n}}},getTaskByName:{value:function(e){for(var t=0;t=f&&H(v);return}return e._state===n?(this.onSubTaskCancel(e),!0):(this._processedIndex=this._processedIndex+1,e.group=this,e.processed=!0,e.concurrent&&(e.concurrent=this.concurrent),this.logLevel!==a&&(e.logLevel=this.logLevel),e.__onStateChange=function(e,t){e===i?this.group.onSubTaskComplete(this):e===r?this.group.onSubTaskFault(this,t):e===n&&this.group.onSubTaskCancel(this)},e.start(),!1)}},removeSubTask:{value:function(e){if(!e)return;var t=this.tasks.indexOf(e);this.tasks.splice(t,1)}},reset:{value:function(){if(this.tasks){this._currentIndex=0,this._processedIndex=0;for(var e=0;e=t&&this.processSubTask(e)}},canProcessSubTask:{value:function(e){if(!e.dependencies)return!0;var n=e.dependencies.length,r=n,i=0,s=[],o=[];for(var u=0;ut?i++:(o.push(a),s.push(a.displayName))}if(i=c&&H("Cannot process "+e.displayName+" until its dependencies ["+s.join(",")+"] have run");var f=function(t){t.target.off("complete",f),this.processSubTask(e)};for(var l=0;l=n)return;if(this.tasks&&this._currentIndex=l&&H("Skipped: "+e.displayName+" Group: "+this.displayName),this.startNextSubTask())}else this.complete()}}}),R.extend=P;var U=function(e){e.itterationIndex=0,e.complete=function(){this.itterationIndex!==this.count-1?(this.reset(),this.itterationIndex++,this.logLevel>=l&&H("Completed:"+this.displayName+" "+this.itterationIndex+" out of "+this.count+" times"),this.performTask()):F.prototype.complete.call(this)}},z=function(t){t.interval=t.interval?t.interval:p,t.complete=function(){if(this.doWhile()){this._state=e;var t=this;this.interval!==0?setTimeout(function(){t.reset(),t.start()},this.interval):t.start()}else F.prototype.complete.call(this)}},W=function(e){e.interval=e.interval?e.interval:p,e.start=function(){var e=this,t=setInterval(function(){e.when()&&(F.prototype.start.call(e),clearInterval(this))},this.interval)}};x.TaskStates={Initialized:e,Started:t,Canceled:n,Faulted:r,Completed:i},x.TaskTypes={Parallel:s,Sequence:o,Simple:u},x.LogLevels={None:a,Error:f,Info:l,Verbose:c}}).call(this); \ No newline at end of file +(function(){"use strict";var e=0,t=1,n=2,r=3,i=4,s="parallel",o="sequence",u="simple",a=0,f=10,l=20,c=30,h="task",p=100,d="Override Needed",v="Undefined Task",m="No Attributes",g="Unknown Task Type",y="Invalid Arguments",b="Unhandled 'postMessage'",w=this,E=0,S=["name","tid","data","type","concurrent","worker","displayName","state","logLevel","timeout","dependencies","group","processed","tasks","max","count","interval"],x=w.MonkeyBars={};typeof exports!="undefined"&&typeof module!="undefined"&&module.exports&&(exports=module.exports=x);var T=function(e){if(!e){e.logLevel>=f&&H(m);return}var t;if(e.tid)t=e;else{var n=e.type,r=e.tasks;r&&(e.tasks=N(r));if(n)if(n===u)t=new F(e);else if(n===o)t=new R(e);else{if(n!==s)throw g;t=new q(e)}else r?t=new R(e):t=new F(e)}return t},N=function(e){var t=[];if(e)for(var n=0;nf&&H(b+": "+A(e.data))},r.onerror=function(e){t.fault("WebWorker error.")},r},_=function(e){if(typeof Worker=="undefined"||typeof Blob=="undefined"||e.type!==u){e.performTask();return}var t=M(O(e),e);t.postMessage()},D=function(e,t){e.count&&U(e),e.when&&W(e),e.doWhile&&z(e)},P=function(e){var t=this,n=function(){t.apply(this,arguments)},r=C(e);return n.prototype=Object.create(t.prototype,r),n},H=function(e){console&&console.log&&console.log(e)},B={_eventMap:undefined,has:function(e){return this._eventMap===undefined||this._eventMap[e]===undefined?!1:!0},off:function(e,t){if(this._eventMap===undefined||this._eventMap[e]===undefined)return;if(e)if(t){var n=[];for(var r=0;rt)return;this._state=n,this.logLevel>=l&&H("Canceled: "+this.displayName),this.timeoutId&&clearTimeout(this.timeoutId),this.trigger("cancel"),this.__onStateChange(this._state),this.onCancel()}},complete:{value:function(e){if(this._state>t)return;this._state=i,this.logLevel>=l&&H("Completed: "+this.displayName),this.timeoutId&&clearTimeout(this.timeoutId),arguments.length!==0&&this.operate(e,this),this.trigger("complete"),this.onComplete(),this.__onStateChange(this._state)},writable:!0},destroy:{value:function(){for(var e in this)this.hasOwnProperty(e)&&delete this[e]}},displayName:{get:function(){return this.name?this.name:this.type+":"+this.tid}},fault:{value:function(e){if(this._state>=n)return;this._state=r,this.logLevel>=l&&H("Faulted: "+this.displayName),this.timeoutId&&clearTimeout(this.timeoutId),this.trigger("fault"),this.__onStateChange(this._state,e),this.onFault(e)}},initialize:{value:function(e){},writable:!0},onCancel:{value:function(){},writable:!0},onComplete:{value:function(){},writable:!0},onFault:{value:function(e){},writable:!0},onStart:{value:function(){},writable:!0},operate:{value:function(e,t){this.data=e},writable:!0},performTask:{value:function(){throw"performTask: "+d},writable:!0},reset:{value:function(){this._state=e,this.processed=!1}},start:{value:function(){if(this._state>=t)return;this._state=t,this.logLevel>=l&&H("Started: "+this.displayName);if(this.timeout!==undefined){var e=this;this.timeoutId=setTimeout(function(){e.fault()},this.timeout)}this.trigger("start"),this.__onStateChange(this._state),this.concurrent?_(this):this.performTask(),this.onStart()},writable:!0},state:{get:function(){return this._state}}}),F.extend=P;var I=x.TaskGroup=function(e){var t=this;e&&e.tasks&&(t.tasks=N(e.tasks));if(t.tasks)for(var n=0;ne?r.cancel():r._state=n}}},getTaskByName:{value:function(e){for(var t=0;t=f&&H(v);return}return e._state===n?(this.onSubTaskCancel(e),!0):(this._processedIndex=this._processedIndex+1,e.group=this,e.processed=!0,e.concurrent&&(e.concurrent=this.concurrent),this.logLevel!==a&&(e.logLevel=this.logLevel),e.__onStateChange=function(e,t){e===i?this.group.onSubTaskComplete(this):e===r?this.group.onSubTaskFault(this,t):e===n&&this.group.onSubTaskCancel(this)},e.start(),!1)}},removeSubTask:{value:function(e){if(!e)return;var t=this.tasks.indexOf(e);this.tasks.splice(t,1)}},reset:{value:function(){if(this.tasks){this._currentIndex=0,this._processedIndex=0;for(var e=0;e=t&&this.processSubTask(e)}},canProcessSubTask:{value:function(e){if(!e.dependencies)return!0;var n=e.dependencies.length,r=n,i=0,s=[],o=[];for(var u=0;ut?i++:(o.push(a),s.push(a.displayName))}if(i=c&&H("Cannot process "+e.displayName+" until its dependencies ["+s.join(",")+"] have run");var f=function(t){t.target.off("complete",f),this.processSubTask(e)};for(var l=0;l=n)return;if(this.tasks&&this._currentIndex=l&&H("Skipped: "+e.displayName+" Group: "+this.displayName),this.startNextSubTask())}else this.complete()}}}),R.extend=P;var U=function(e){e.itterationIndex=0,e.complete=function(){this.itterationIndex!==this.count-1?(this.reset(),this.itterationIndex++,this.logLevel>=l&&H("Completed:"+this.displayName+" "+this.itterationIndex+" out of "+this.count+" times"),this.performTask()):F.prototype.complete.call(this)}},z=function(t){t.interval=t.interval?t.interval:p,t.complete=function(){if(this.doWhile()){this._state=e;var t=this;this.interval!==0?setTimeout(function(){t.reset(),t.start()},this.interval):t.start()}else F.prototype.complete.call(this)}},W=function(e){e.interval=e.interval?e.interval:p,e.start=function(){var e=this,t=setInterval(function(){e.when()&&(F.prototype.start.call(e),clearInterval(this))},this.interval)}};x.TaskStates={Initialized:e,Started:t,Canceled:n,Faulted:r,Completed:i},x.TaskTypes={Parallel:s,Sequence:o,Simple:u},x.LogLevels={None:a,Error:f,Info:l,Verbose:c}}).call(this); \ No newline at end of file diff --git a/source/group.js b/source/group.js index d38d197..bf7aa44 100644 --- a/source/group.js +++ b/source/group.js @@ -44,7 +44,8 @@ TaskGroup.prototype = Object.create(Task.prototype, { * @private */ _dependencyMap: { - value:{} + value:{}, + writable:true }, /** @@ -254,7 +255,8 @@ TaskGroup.prototype = Object.create(Task.prototype, { this.tasks[i]._state = STATE_CANCELED; } } - } + }, + writable:true }, /** @@ -267,7 +269,8 @@ TaskGroup.prototype = Object.create(Task.prototype, { onSubTaskComplete: { value: function(task) { task.group.operate(task.data,task); - } + }, + writable:true }, /** @@ -280,7 +283,8 @@ TaskGroup.prototype = Object.create(Task.prototype, { onSubTaskFault: { value: function(task, error) { this.fault(error); - } + }, + writable:true }, /** @@ -379,6 +383,20 @@ TaskGroup.prototype = Object.create(Task.prototype, { var totalDependencies = task.dependencies.length; for(var i = 0; i < totalDependencies; i++) { var dependency = task.dependencies[i]; + + // if the depoendency is not an actual task then we need to find that + // task and reassign the dependency with the instance + if(dependency.tid === undefined) { + var t = this.getTaskByTid(dependency); + if(t === undefined) { + t = this.getTaskByName(dependency); + } + if(t !== undefined) { + dependency = task.dependencies[i] = t; + } + } + + // set the dependency to the groups dependency map if(dependency.tid) { this._dependencyMap[task.tid].push(dependency.tid); } else { diff --git a/source/parallel.js b/source/parallel.js index 90048e3..05f1796 100644 --- a/source/parallel.js +++ b/source/parallel.js @@ -1,3 +1,14 @@ +/* + + @TODO: going to have to work on the processing flow to do the following: + + 1. start is called on group + 2. process all sub tasks + 3. performTask + 4. start all sub tasks that can be started + +*/ + /** * A ParallelTask is a TaskGroup that runs all of its subtasks ansynchronously. Its * complete functionality is run when all of its sub tasks are complete. @@ -103,6 +114,8 @@ ParallelTask.prototype = Object.create(TaskGroup.prototype, { }; for (var j = 0; j < dependencies.length; j++) { var t = dependencies[j]; + console.log("add event"); + console.log(t); t.on("complete",completion,this,false); } return false; @@ -147,7 +160,8 @@ ParallelTask.prototype = Object.create(TaskGroup.prototype, { if(this._currentIndex === this.tasks.length) { this.complete(); } - } + }, + writable:true }, /** @@ -164,7 +178,8 @@ ParallelTask.prototype = Object.create(TaskGroup.prototype, { } else { this.processSubTasks(); } - } + }, + writable:true }, /** diff --git a/source/sequence.js b/source/sequence.js index b4d651c..294936a 100644 --- a/source/sequence.js +++ b/source/sequence.js @@ -58,7 +58,8 @@ SequenceTask.prototype = Object.create(TaskGroup.prototype, { if(this._state !== STATE_CANCELED) { this.startNextSubTask(); } - } + }, + writable:true }, /** @@ -79,7 +80,8 @@ SequenceTask.prototype = Object.create(TaskGroup.prototype, { TaskGroup.prototype.onSubTaskComplete.call(this, task); delegate.startNextSubTask(); },0); - } + }, + writable:true }, /** @@ -92,7 +94,8 @@ SequenceTask.prototype = Object.create(TaskGroup.prototype, { performTask: { value: function() { this.startNextSubTask(); - } + }, + writable:true }, /** diff --git a/source/simple.js b/source/simple.js index 98ca55f..2775c2b 100644 --- a/source/simple.js +++ b/source/simple.js @@ -70,7 +70,8 @@ Task.prototype = Object.create(TaskEvents, { * @private */ _state: { - value: STATE_INITIALIZED + value: STATE_INITIALIZED, + writable:true }, // =================================================================== @@ -85,7 +86,8 @@ Task.prototype = Object.create(TaskEvents, { * @default false */ concurrent: { - value: false + value: false, + writable:true }, /** @@ -150,7 +152,8 @@ Task.prototype = Object.create(TaskEvents, { * }); */ worker: { - value: undefined + value: undefined, + writable:true }, // =================================================================== @@ -167,7 +170,8 @@ Task.prototype = Object.create(TaskEvents, { * @private */ __onStateChange: { - value: function(state, error) {} + value: function(state, error) {}, + writable: true }, // =================================================================== @@ -246,7 +250,8 @@ Task.prototype = Object.create(TaskEvents, { this.trigger("complete"); this.onComplete(); this.__onStateChange(this._state); - } + }, + writable:true }, /** @@ -302,7 +307,8 @@ Task.prototype = Object.create(TaskEvents, { value: function(error) { if(this._state >= STATE_CANCELED) { return; - } this._state = STATE_FAULTED; + } + this._state = STATE_FAULTED; if(this.logLevel >= LOG_INFO) { log("Faulted: " + this.displayName); } @@ -322,7 +328,8 @@ Task.prototype = Object.create(TaskEvents, { * @param {Object} attributes */ initialize: { - value: function(attributes) {} + value: function(attributes) {}, + writable:true }, /** @@ -331,7 +338,8 @@ Task.prototype = Object.create(TaskEvents, { * @method onCancel */ onCancel: { - value: function() {} + value: function() {}, + writable:true }, /** @@ -340,7 +348,8 @@ Task.prototype = Object.create(TaskEvents, { * @method onComplete */ onComplete: { - value: function() {} + value: function() {}, + writable:true }, /** @@ -350,7 +359,8 @@ Task.prototype = Object.create(TaskEvents, { * @param {String} error Message describing error */ onFault: { - value: function(error) {} + value: function(error) {}, + writable:true }, /** @@ -359,7 +369,8 @@ Task.prototype = Object.create(TaskEvents, { * @method onStart */ onStart: { - value: function() {} + value: function() {}, + writable:true }, /** @@ -371,7 +382,8 @@ Task.prototype = Object.create(TaskEvents, { operate:{ value:function(data, task){ this.data = data; - } + }, + writable:true }, /** @@ -395,7 +407,8 @@ Task.prototype = Object.create(TaskEvents, { performTask: { value: function() { throw "performTask: " + OVERRIDE_NEEDED; - } + }, + writable:true }, /** @@ -441,7 +454,8 @@ Task.prototype = Object.create(TaskEvents, { } this.onStart(); - } + }, + writable:true }, /** diff --git a/tests/index.html b/tests/index.html index d7e64ce..b8b2df4 100644 --- a/tests/index.html +++ b/tests/index.html @@ -26,7 +26,7 @@ - +