TaskQueue()

This class is used for task management. Tasks are processed in an asynchronous way when there is idle time within a single simulation step or after a defined amount of time (deadline). The class is a wrapper around requestidlecallback(), a JavaScript API for cooperative scheduling of background tasks.

new TaskQueue()

Constructs a new task queue.

Author:

Members

options :Object

Used to control the asynchronous processing.

  • timeout: After this amount of time (in ms), a scheduled task is executed even if doing so risks causing a negative performance impact (e.g. bad frame time).

readonly tasks :Array.<Task>

A list of pending tasks.

Methods

enqueue(task) → {TaskQueue}

Adds the given task to the task queue.

Parameters:
Name Type Description
task Task

The task to add.

Returns:
TaskQueue -

A reference to this task queue.

update() → {TaskQueue}

Updates the internal state of the task queue. Should be called per simulation step.

Returns:
TaskQueue -

A reference to this task queue.