Runner

Class representing a task runner.

Constructor

new Runner()

Create a task runner

Parameters:
NameTypeAttributesDefaultDescription
options.parallelNumber<optional>
10

Number of parallel foreground tasks can be run in parallel

options.restartDelayMsNumber<optional>
5000

Number of milliseconds to wait before restarting a task during task resets

options.planningIntervalMsNumber<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

Parameters:
NameTypeDescription
taskTasker.Task
Returns:
Type: 
Tasker.Task

allDone(taskList)

Check if the entire task list is complete

Parameters:
NameTypeDescription
taskListArray.<string>
Returns:

bool

canRun(task)

Can the task be run

Parameters:
NameTypeDescription
taskTasker.Task
Returns:

bool

(async) cancelTask(taskName) → {Promise.<any>}

Cancel task, returns the result of the Tasker.Task.cancel() function.

Parameters:
NameTypeDescription
taskNamestring
Returns:
Type: 
Promise.<any>

collectResults(nameList) → {any}

Get collection of task results

Parameters:
NameTypeDescription
nameListArray.<string>

List of task results to lookup

Returns:
Type: 
any

exists(taskName)

Does task exist in runner?

Parameters:
NameTypeDescription
taskNamestring
Returns:

bool

getTask(taskName) → {Tasker.Task}

Lookup task instance

Parameters:
NameTypeDescription
taskNamestring
Returns:
Type: 
Tasker.Task

hasWork()

Check if the there are pending or running tasks

Returns:

bool

isDone(taskName)

Check if the task list is done

Parameters:
NameTypeDescription
taskNamestring
Returns:

bool

isPending(taskName)

Check if the task list is pending

Parameters:
NameTypeDescription
taskNamestring
Returns:

bool

isRunning(taskName)

Check if the task list is running

Parameters:
NameTypeDescription
taskNamestring
Returns:

bool

resetTask(taskName, timeout)

Call the reset function on the named task

Parameters:
NameTypeDescription
taskNamestring
timeoutNumber

Timeout ms. Defaults to restartDelayMs provided in constructor

restartTask(taskName, timeout)

Call the reset function on the named task and reschedule task.

Parameters:
NameTypeDescription
taskNamestring
timeoutNumber

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.

Parameters:
NameTypeDescription
namestring

Task name

Returns:
Type: 
TaskState

Events

idle

Idle event.

running

Running event.

task-done

Task done event.

Type:

task-failure

Task failure event.

Type:

task-success

Task success event.

Type: