Constructor
new Runner()
Create a task runner
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options.parallel | Number | <optional> | 10 | Number of parallel foreground tasks can be run in parallel |
options.restartDelayMs | Number | <optional> | 5000 | Number of milliseconds to wait before restarting a task during task resets |
options.planningIntervalMs | Number | <optional> | 100 | Number of milliseconds between planning watchdog timer |
Members
depends
An array of tasks in the order initially added.
runOrder
List of task names in dependency resolved order
tasks
A collection mapping task names to Task instances.
Methods
(async) addTask(task) → {Tasker.Task}
Add task to run queue
Name | Type | Description |
---|---|---|
task | Tasker. |
- Type:
- Tasker.
Task
allDone(taskList)
Check if the entire task list is complete
Name | Type | Description |
---|---|---|
taskList | Array.<string> |
bool
canRun(task)
Can the task be run
Name | Type | Description |
---|---|---|
task | Tasker. |
bool
(async) cancelTask(taskName) → {Promise.<any>}
Cancel task, returns the result of the Tasker.Task.cancel() function.
Name | Type | Description |
---|---|---|
taskName | string |
- Type:
- Promise.<any>
collectResults(nameList) → {any}
Get collection of task results
Name | Type | Description |
---|---|---|
nameList | Array.<string> | List of task results to lookup |
- Type:
- any
exists(taskName)
Does task exist in runner?
Name | Type | Description |
---|---|---|
taskName | string |
bool
getTask(taskName) → {Tasker.Task}
Lookup task instance
Name | Type | Description |
---|---|---|
taskName | string |
- Type:
- Tasker.
Task
hasWork()
Check if the there are pending or running tasks
bool
isDone(taskName)
Check if the task list is done
Name | Type | Description |
---|---|---|
taskName | string |
bool
isPending(taskName)
Check if the task list is pending
Name | Type | Description |
---|---|---|
taskName | string |
bool
isRunning(taskName)
Check if the task list is running
Name | Type | Description |
---|---|---|
taskName | string |
bool
resetTask(taskName, timeout)
Call the reset function on the named task
Name | Type | Description |
---|---|---|
taskName | string | |
timeout | Number | Timeout ms. Defaults to restartDelayMs provided in constructor |
restartTask(taskName, timeout)
Call the reset function on the named task and reschedule task.
Name | Type | Description |
---|---|---|
taskName | string | |
timeout | Number | Timeout ms. Defaults to restartDelayMs provided in constructor |
runTasks()
Execute tasks
(async) start()
Start task runner
(async) stop()
Stop running tasks. Calls Task.cancel on all running and pending tasks. Then resets all tasks.
taskState(name) → {TaskState}
Lookup task state.
Name | Type | Description |
---|---|---|
name | string | Task name |
- Type:
- TaskState
Events
idle
Idle event.
running
Running event.
task-done
Task done event.
task-failure
Task failure event.
task-success
Task success event.