Interface ScheduledSource<T extends Event>

Type Parameters:
T - The type of events this event source creates.
All Superinterfaces:
EventSource<T>, Runnable
All Known Subinterfaces:
TimeScheduleSource
All Known Implementing Classes:
ScheduledProcessStartSource

public interface ScheduledSource<T extends Event> extends EventSource<T>
An event source which names the times at which it runs, instead of being polled at a fixed rate. The event manager runs it at the time getNextRunTime() names and asks for the next time when the run has ended, however it has ended, until the source names none. A run decides itself whether it creates an event; if it creates one, it performs the handling before it returns.

The source does not need to take care of its deactivation: removing it cancels its pending run, while a run in progress completes, and calls terminate(). A source added in place of a removed one runs first when the removed one's run in progress has ended.

  • Method Details

    • getNextRunTime

      Instant getNextRunTime()
      Gets the time at which the event manager is to run this source next. A time which has passed lets the source run at once. This is called when the source is added, for a source added in place of a removed one when the removed one's run in progress has ended, and whenever a run of it has ended.
      Returns:
      The time at which this source is to run next or null if it has ended and is not to run any more.
    • terminate

      default void terminate()
      Terminates this scheduled source. This is called once when the source is removed, after its pending run has been cancelled.
      Note that this may be called while the source runs, so the implementation has to synchronise appropriately.