Class AbstractEventManager.ScheduledRuns

java.lang.Object
de.aristaflow.adept2.core.eventmanager.common.AbstractEventManager.ScheduledRuns
All Implemented Interfaces:
Runnable
Enclosing class:
AbstractEventManager

protected class AbstractEventManager.ScheduledRuns extends Object implements Runnable
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

    Fields
    Modifier and Type
    Field
    Description
    protected final CompletableFuture<Void>
    The future of the runs, completed when they end; its completion cancels the pending run.
    protected final Supplier<Instant>
    The supplier of the time of the next run, null ending the runs.
    protected Future<?>
    The future of the pending run, null while none is pending.
    The stage of the run in progress, which completes when the run has ended, null while no run is in progress.
    protected final Runnable
    The task to run.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ScheduledRuns(Runnable task, Supplier<Instant> nextRunTime)
    Creates the runs of the designated task at the times the designated supplier names.
  • Method Summary

    Modifier and Type
    Method
    Description
    Cancels these runs, the pending run and every further one, and returns the end of the run in progress, which completes.
    protected final void
    Cancels the pending run, if there is one.
    void
    run()
     
    protected void
    Schedules the next run at the time the supplier names, unless the runs have ended or have been cancelled.
    Returns the string form of the task, which the poll executor names when it logs an exception of a run.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • task

      protected final Runnable task
      The task to run.
    • nextRunTime

      protected final Supplier<Instant> nextRunTime
      The supplier of the time of the next run, null ending the runs.
    • future

      protected final CompletableFuture<Void> future
      The future of the runs, completed when they end; its completion cancels the pending run.
    • pending

      protected Future<?> pending
      The future of the pending run, null while none is pending.
    • running

      protected CompletableFuture<Void> running
      The stage of the run in progress, which completes when the run has ended, null while no run is in progress.
  • Constructor Details

    • ScheduledRuns

      protected ScheduledRuns(Runnable task, Supplier<Instant> nextRunTime)
      Creates the runs of the designated task at the times the designated supplier names. Nothing is scheduled before scheduleNext().
      Parameters:
      task - The task to run.
      nextRunTime - The supplier of the time of the next run, null ending the runs.
  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable
    • 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

      protected CompletionStage<Void> 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, null if no run is in progress.
    • cancelPending

      protected final void cancelPending()
      Cancels the pending run, if there is one. A run in progress completes.
    • toString

      public String toString()
      Returns the string form of the task, which the poll executor names when it logs an exception of a run.
      Overrides:
      toString in class Object
      Returns:
      The string form of the task.