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. | |
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. | |
void | clearTasks (Stage stage) |
Removes all tasks in a stage. | |
void | enableSuspendWhenIdle (boolean suspendEnabled) |
Sets whether an application allows suspension. | |
boolean | isCurrentFrameRendered () |
Returns whether rendering was performed in the current frame. | |
boolean | isSuspendWhenIdleEnabled () |
Returns whether an application allows suspension. | |
TaskToken | prependTask (Stage stage, String name, TaskRecurrence recurrence, Task task) |
Adds a task to the front of a stage. | |
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. | |
boolean | removeTask (Stage stage, TaskToken token) |
Removes a task from a stage. | |
boolean | removeTimer (TimerToken token) |
Removes a timer task from the main loop. | |
boolean | replaceTask (Stage stage, TaskToken token, Task task) |
Replaces a task in a stage with another one. | |
void | setCurrentFrameRendered () |
Sets whether rendering was performed in the current frame. | |
void | setFrameRateLimit (long frameRate) |
Sets the frame rate limit of the application. | |
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. | |
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. |
Removes all tasks in a stage.
stage | The stage where to remove the tasks. |
Sets whether an application allows suspension.
suspendEnabled | If the application allows suspension, use true, otherwise false. |
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.
boolean isSuspendWhenIdleEnabled | ( | ) |
Returns whether an application allows suspension.
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.
Sets the frame rate limit of the application.
This sets an upper limit on the number of frames rendered by Kanzi every second.
frameRate | The number of frames to render every second. To disable frame rate limit, use 0. |
|
static |
Stage for executing your application code.
Includes: