Class SchedulableTick
A tickable task is expected to be self scheduled using the setScheduledStart(long) during
every tick.
A tickable task can have intermediate tasks that can be executed before its tick method is run. Instead of the scheduled thread pool parking in-between ticks, the scheduler may instead drain intermediate tasks from scheduled tasks. The parsing of intermediate tasks allows the scheduler to take advantage of time in-between ticks to reduce the intermediate task load from tasks once they begin ticking or to possibly reduce latency parsing intermediate tasks.
It is guaranteed that runTick() and runTasks(BooleanSupplier) are never
invoked in parallel.
It is required that when intermediate tasks are scheduled, that the scheduler's notify task function is invoked for any scheduled task - otherwise, the scheduler may not parse intermediate tasks.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final longabstract booleanhasTasks()Returns whether this task has any intermediate tasks that can be executed.abstract booleanrunTasks(BooleanSupplier canContinue) abstract booleanrunTick()Executes the tick.protected final voidsetScheduledStart(long value) If this task is scheduled, then this may only be invoked duringrunTick()toString()
-
Field Details
-
id
public final long id
-
-
Constructor Details
-
SchedulableTick
public SchedulableTick()
-
-
Method Details
-
getScheduledStart
protected final long getScheduledStart() -
setScheduledStart
protected final void setScheduledStart(long value) If this task is scheduled, then this may only be invoked duringrunTick() -
runTick
public abstract boolean runTick()Executes the tick.It is the callee's responsibility to invoke
setScheduledStart(long)to adjust the start of the next tick.- Returns:
trueif this task should continue to be scheduled,falseotherwise.
-
hasTasks
public abstract boolean hasTasks()Returns whether this task has any intermediate tasks that can be executed. -
runTasks
- Returns:
trueif this task should continue to be scheduled,falseotherwise.
-
toString
-