Class AbstractEventManager.ScheduledRuns
java.lang.Object
de.aristaflow.adept2.core.eventmanager.common.AbstractEventManager.ScheduledRuns
- All Implemented Interfaces:
Runnable
- Enclosing class:
- AbstractEventManager
The runs of a task at the times a supplier names, each run scheduled on the poll executor when
the previous one has ended.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CompletableFuture<Void>The future of the runs, completed when they end; its completion cancels the pending run.The supplier of the time of the next run,nullending the runs.protected Future<?>The future of the pending run,nullwhile none is pending.protected CompletableFuture<Void>The stage of the run in progress, which completes when the run has ended,nullwhile no run is in progress.protected final RunnableThe task to run. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedScheduledRuns(Runnable task, Supplier<Instant> nextRunTime) Creates the runs of the designated task at the times the designated supplier names. -
Method Summary
Modifier and TypeMethodDescriptionprotected CompletionStage<Void>cancel()Cancels these runs, the pending run and every further one, and returns the end of the run in progress, which completes.protected final voidCancels the pending run, if there is one.voidrun()protected voidSchedules the next run at the time the supplier names, unless the runs have ended or have been cancelled.toString()Returns the string form of the task, which the poll executor names when it logs an exception of a run.
-
Field Details
-
task
The task to run. -
nextRunTime
The supplier of the time of the next run,nullending the runs. -
future
The future of the runs, completed when they end; its completion cancels the pending run. -
pending
The future of the pending run,nullwhile none is pending. -
running
The stage of the run in progress, which completes when the run has ended,nullwhile no run is in progress.
-
-
Constructor Details
-
ScheduledRuns
Creates the runs of the designated task at the times the designated supplier names. Nothing is scheduled beforescheduleNext().- Parameters:
task- The task to run.nextRunTime- The supplier of the time of the next run,nullending the runs.
-
-
Method Details
-
run
public void run() -
scheduleNext
protected void scheduleNext()Schedules the next run at the time the supplier names, unless the runs have ended or have been cancelled. The supplier is asked outside the lock of these runs, so that it may take locks of its own while the runs are being cancelled. -
cancel
Cancels these runs, the pending run and every further one, and returns the end of the run in progress, which completes. A run which the poll executor starts after the cancellation is skipped, so that no run but the returned one is still to end.- Returns:
- The stage of the run in progress, which completes when the run has ended,
nullif no run is in progress.
-
cancelPending
protected final void cancelPending()Cancels the pending run, if there is one. A run in progress completes. -
toString
Returns the string form of the task, which the poll executor names when it logs an exception of a run.
-