MainLoopScheduler implements the Kanzi application main loop in form of a sequence of stages, each consisting of a sequence of tasks, where a task is a callable method. More...
Classes | |
class | Stage |
Stage instance represent a Stage in the Kanzi main loop. More... | |
interface | Task |
A task that can be added for one-time or repeated execution by MainLoopScheduler. More... | |
class | TaskToken |
The token of the task. More... | |
interface | TimerTask |
A task that can be scheduled for one-time or repeated execution by MainLoopScheduler. More... | |
class | TimerToken |
The token of the timer task. More... | |
Public Member Functions | |
TaskToken | appendTask (Stage stage, String name, TaskRecurrence recurrence, Task task) |
Adds a task to the back of a stage. More... | |
TimerToken | appendTimer (Stage stage, String name, TimerRecurrence recurrence, Duration interval, TimerTask task) |
Adds a timer task to be executed after a stage in the main loop. More... | |
void | clearTasks (Stage stage) |
Removes all tasks in a stage. More... | |
boolean | isCurrentFrameRendered () |
Returns whether rendering was performed in the current frame. More... | |
TaskToken | prependTask (Stage stage, String name, TaskRecurrence recurrence, Task task) |
Adds a task to the front of a stage. More... | |
TimerToken | prependTimer (Stage stage, String name, TimerRecurrence recurrence, Duration interval, TimerTask task) |
Adds a timer task to be executed before a stage in the main loop. More... | |
boolean | removeTask (Stage stage, TaskToken token) |
Removes a task from a stage. More... | |
boolean | removeTimer (TimerToken token) |
Removes a timer task from the main loop. More... | |
boolean | replaceTask (Stage stage, TaskToken token, Task task) |
Replaces a task in a stage with another one. More... | |
void | setCurrentFrameRendered () |
Sets whether rendering was performed in the current frame. More... | |
Static Public Attributes | |
static Stage | AnimateStage |
Stage for ticking animations. | |
static Stage | InputStage |
Stage for handling input events. | |
static Stage | LayoutStage |
Stage for laying out the nodes. | |
static Stage | PresentStage |
Stage for presenting the nodes. | |
static Stage | RenderStage |
Stage for rendering the nodes. | |
static Stage | UserStage |
Stage for executing your application code. More... | |
MainLoopScheduler implements the Kanzi application main loop in form of a sequence of stages, each consisting of a sequence of tasks, where a task is a callable method.
You can customize the application main loop by extending its stages with additional tasks, replacing existing tasks with your own implementations or adding timer tasks to execute some functionality at regular intervals.
All objects and subsystems in Kanzi are associated with a domain when created. Objects in the same domain share access to the same subsystems. Objects from different domains cannot be used together.
TaskToken appendTask | ( | Stage | stage, |
String | name, | ||
TaskRecurrence | recurrence, | ||
Task | task | ||
) |
Adds a task to the back of a stage.
stage | The stage where to add the task. |
name | Name for the task. |
recurrence | Recurrence choice for the task that you want to insert. |
task | The task that you want to insert. |
TimerToken appendTimer | ( | Stage | stage, |
String | name, | ||
TimerRecurrence | recurrence, | ||
Duration | interval, | ||
TimerTask | task | ||
) |
Adds a timer task to be executed after a stage in the main loop.
stage | The stage where to add the task. |
name | Name for the task. |
recurrence | Recurrence choice for the task that you want to insert. |
interval | The amount of time after which to execute the task. |
task | The task that you want to insert. |
void clearTasks | ( | Stage | stage | ) |
Removes all tasks in a stage.
stage | The stage where to remove the tasks. |
boolean isCurrentFrameRendered | ( | ) |
Returns whether rendering was performed in the current frame.
The main loop uses this as a precondition for executing the Present stage for a frame.
TaskToken prependTask | ( | Stage | stage, |
String | name, | ||
TaskRecurrence | recurrence, | ||
Task | task | ||
) |
Adds a task to the front of a stage.
stage | The stage where to add the task. |
name | Name for the task. |
recurrence | Recurrence choice for the task that you want to insert. |
task | The task that you want to insert. |
TimerToken prependTimer | ( | Stage | stage, |
String | name, | ||
TimerRecurrence | recurrence, | ||
Duration | interval, | ||
TimerTask | task | ||
) |
Adds a timer task to be executed before a stage in the main loop.
stage | The stage where to add the task. |
name | Name for the task. |
recurrence | Recurrence choice for the task that you want to insert. |
interval | The amount of time after which to execute the task. |
task | The task that you want to insert. |
Removes a task from a stage.
stage | The stage where to remove the task. |
token | Token of the task. |
boolean removeTimer | ( | TimerToken | token | ) |
Removes a timer task from the main loop.
token | Token of the task. |
Replaces a task in a stage with another one.
stage | The stage where to replace the task. |
token | Token of the task. |
task | The task with which to replace the current task. |
void setCurrentFrameRendered | ( | ) |
Sets whether rendering was performed in the current frame.
Call this function from a task in the Render stage to inform the main loop that the task performed rendering. The main loop uses this as a precondition for executing the Present stage for a frame.