Class GuiScheduler
java.lang.Object
com.ultikits.ultitools.abstracts.gui.declarative.engine.GuiScheduler
Marshals GUI work onto the viewer's entity context using the framework scheduler.
A frame is always deferred to the next tick. Repeated requests for the same Runnable are coalesced;
distinct tasks share that frame. Tasks queued during a drain run on a later frame, bounding the work
of even a widget whose initState requests a rebuild and then throws.
- Since:
- 6.2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TaskContextprivate booleanprivate TaskHandleprivate booleanprivate longprivate final Set<TaskHandle> -
Constructor Summary
ConstructorsConstructorDescriptionGuiScheduler(@NotNull Scheduler scheduler, @NotNull org.bukkit.entity.Player viewer) -
Method Summary
Modifier and TypeMethodDescriptionvoidCancels every submitted handle as well as pending frames; the scheduler may be reused afterwards.private voidprivate voidvoidflush()Drains pending frame work synchronously, ignoring the normal per-frame budget (for tests).booleanprivate voidlogFrameTaskError(Throwable failure) private Runnableprivate voidprivate voidrunDeferred(Runnable task) voidrunOnMainThread(@NotNull Runnable task) Runs synchronously on the owning thread, otherwise submits tracked work there.private voidrunSynchronous(Runnable task) voidscheduleFrame(@NotNull Runnable frameTask) private voidprivate TaskHandleCalled with the queue monitor held; TaskContext.run never runs inline.
-
Field Details
-
context
-
pendingTasks
-
submitted
-
frameHandle
-
frameScheduled
private boolean frameScheduled -
flushing
private boolean flushing -
generation
private long generation
-
-
Constructor Details
-
GuiScheduler
public GuiScheduler(@NotNull @NotNull Scheduler scheduler, @NotNull @NotNull org.bukkit.entity.Player viewer) - Parameters:
scheduler- the module's own injected schedulerviewer- the entity whose screen is being built
-
-
Method Details
-
isOnMainThread
public boolean isOnMainThread()- Returns:
- whether the caller currently owns the viewer's entity context
-
runOnMainThread
Runs synchronously on the owning thread, otherwise submits tracked work there. A synchronous depth failure is reported and rethrown. Deferred failures are logged; JVM Errors are then rethrown unchanged to the scheduling engine.- Parameters:
task- the work to execute
-
scheduleFrame
- Parameters:
frameTask- the stable frame callback to enqueue, at most once per pending frame
-
schedulePendingFrame
private void schedulePendingFrame() -
submit
Called with the queue monitor held; TaskContext.run never runs inline. -
executeFrame
private void executeFrame() -
runSynchronous
-
runDeferred
-
logFrameTaskError
-
reportRenderDepthExceeded
-
flush
public void flush()Drains pending frame work synchronously, ignoring the normal per-frame budget (for tests).- Throws:
IllegalStateException- if the caller does not own the viewer's context
-
pollPending
-
cancelFrame
private void cancelFrame() -
cancelAll
public void cancelAll()Cancels every submitted handle as well as pending frames; the scheduler may be reused afterwards.
-