Module: ExecutorInterface

ExecutorInterface

This module defines a common interface to be used to implement a task executor singleton.
The implementation should guarantee that, given two tasks to be executed at the same time, they are served in a FIFO fashion.

Method Summary

addPackedTimedTask
Queue a previously generated task for later execution.
addRepetitiveTask
Creates and enqueue a Task to be executed at fixed intervals.
addTimedTask
Creates and enqueue a Task to be later executed.
delayTask
Delays the execution of a task.
executeTask
Executed a previously generated task.
getQueueLength
Get the number of tasks in the executor queue.
modifyAllTaskParams
Replaces the parameters array for a specified task.
modifyTaskParam
Replaces one of the parameters of a specified task.
packTask
Creates a task object to be later executed.
stopRepetitiveTask
Stop the executions of a repetitive task.

Method Detail

<static> addPackedTimedTask(task, time, repetitive)

Queue a previously generated task for later execution.
Parameters:
Name Type Argument Default Description
task Task the task to be queued.
time Number the time that should be waited before executing the task. If the repetitive flag is true this time specifies the interval between two executions.
repetitive Boolean <optional>
false true if the task has to be executed at fixed intervals, false if it has to be executed only once.

<static> addRepetitiveTask(fun, interval, context, params)

Creates and enqueue a Task to be executed at fixed intervals.
Parameters:
Name Type Argument Description
fun function the function to be executed.
interval Number the time that should be waited between each task execution.
context Object <optional>
the object to be used as context for the function call.
params Array <optional>
the parameters to be passed to the function.
See:
  • stopRepetitiveTask

<static> addTimedTask(fun, time, context, params, repetitive)

Creates and enqueue a Task to be later executed.
Parameters:
Name Type Argument Default Description
fun function the function to be executed.
time Number the time that should be waited before executing the task. If the repetitive flag is true this time specifies the interval between two executions.
context Object <optional>
the object to be used as context for the function call.
params Array <optional>
the parameters to be passed to the function.
repetitive Boolean <optional>
false true if the task has to be executed at fixed intervals, false if it has to be executed only once.

<static> delayTask(task, delay)

Delays the execution of a task.
Parameters:
Name Type Description
task Task the task to be delayed.
delay Number the extra time that should be waited before executing the task.

<static> executeTask(task, extParams)

Executed a previously generated task.
Parameters:
Name Type Argument Description
task Task the task to be executed.
extParams Array <optional>
an array of params to replace the task's own array. If missing the original array is used.
See:
  • packTask

<static> getQueueLength() → {Number}

Get the number of tasks in the executor queue.
Returns:
the number of task to be executed.
Type
Number

<static> modifyAllTaskParams(task, extParams)

Replaces the parameters array for a specified task.
Parameters:
Name Type Description
task Task the task to be modified.
extParams Array the new array to be passed to the task.

<static> modifyTaskParam(task, index, newParam)

Replaces one of the parameters of a specified task.
Parameters:
Name Type Description
task Task the task to be modified.
index Number the 0-based index within the previously specified array of parameters to be replaced.
newParam Object the value to replace the previous parameter.

<static> packTask(fun, context, params) → {Task}

Creates a task object to be later executed.
Note: the task is not queued for execution.
The returned object does not need to be cross-compatible with other ExecutorInterface implementation: only the involved implementation is supposed to accept the generated task.
Parameters:
Name Type Argument Description
fun function the function to be executed.
context Object <optional>
the object to be used as context for the function call.
params Array <optional>
the parameters to be passed to the function.
Returns:
an object representing the task to be executed.
Type
Task

<static> stopRepetitiveTask(task)

Stop the executions of a repetitive task.
Parameters:
Name Type Description
task Task the task to be stopped.