Skip to content

Task

final class Task
Package: dev.joid.lib.ui.task · Module: core · Source: Task.java

Code that runs once after a delay, or on a period, while it is attached to a UI or a node.

Runs its listeners on the render thread while its UI or its node is drawn (Know how long a task lives).

ReturnsSignatureSummary
Taskcreate(long delay) factoryCreates a task that runs once, this many ms after it is attached.

ReturnsSignatureSummary
thisattach(UI ui) fluentAttaches the task to the UI and starts counting its delay; it leaves its previous owner first.
thisattach(Node node) fluentAttaches the task to the node and starts counting its delay.
thisdetach() fluentDetaches the task, which stops running.
booleanisAttached()If true, the task has a UI or a node.
ReturnsSignatureSummary
booleanisDue()If true, the task is attached and its next run time has come.
longgetDelay()Time, in ms, between the attach and the first run.
EventBusgetEventBus()The listeners of the task.
longgetPeriod()Time, in ms, between two runs; negative for a task that runs once.
longgetNextRun()Time of the next run, in nanoseconds of the clock bridge (nanoTime()).
UIgetUi()The UI the task is attached to, or null.
NodegetNode()The node the task is attached to, or null.
ReturnsSignatureSummary
thisevery(long period) fluentMakes the task run again every period ms after its first run, until it is detached.
thisowner(UI ui, Node node) fluentRecords the owner of the task and, when it has one, starts counting its delay.
ReturnsSignatureSummary
voidfireRun()Runs the listeners now and plans the next run, or detaches a one-shot task.

EventListenerSummary
onRunEventListener<TaskEvent>Adds a listener that runs each time the task runs.

Task create(long delay) factory

Creates a task that runs once, this many ms after it is attached.

this attach(UI ui) fluent

Attaches the task to the UI and starts counting its delay; it leaves its previous owner first.

this attach(Node node) fluent

Attaches the task to the node and starts counting its delay.

this detach() fluent

Detaches the task, which stops running.

boolean isAttached()

If true, the task has a UI or a node.

boolean isDue()

If true, the task is attached and its next run time has come.

long getDelay()

Time, in ms, between the attach and the first run.

EventBus getEventBus()

The listeners of the task.

long getPeriod()

Time, in ms, between two runs; negative for a task that runs once.

long getNextRun()

Time of the next run, in nanoseconds of the clock bridge (nanoTime()).

UI getUi()

The UI the task is attached to, or null.

Node getNode()

The node the task is attached to, or null.

this every(long period) fluent

Makes the task run again every period ms after its first run, until it is detached.

this owner(UI ui, Node node) fluent

Records the owner of the task and, when it has one, starts counting its delay. UI.addTask and Node.addTask call it; you attach with attach.

void fireRun()

Runs the listeners now and plans the next run, or detaches a one-shot task. The UI calls it when the task is due.

this onRun(EventListener<TaskEvent> listener) fluent

Adds a listener that runs each time the task runs.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page