Class DefaultEventScheduler

java.lang.Object
org.eclipse.mosaic.lib.util.scheduling.DefaultEventScheduler
All Implemented Interfaces:
EventManager, EventScheduler
Direct Known Subclasses:
MultiThreadedEventScheduler

public class DefaultEventScheduler extends Object implements EventScheduler
The event scheduler implementation is a sequential implementation of the event scheduler.
  • Field Details

    • eventQueue

      protected final PriorityQueue<Event> eventQueue
      The queue stores and sorts the events.
    • scheduledTime

      protected long scheduledTime
      The last scheduled time.
  • Constructor Details

    • DefaultEventScheduler

      public DefaultEventScheduler()
  • Method Details

    • addEvent

      public void addEvent(@Nonnull Event event)
      Description copied from interface: EventManager
      Add an Event to the scheduler.
      Specified by:
      addEvent in interface EventManager
      Parameters:
      event - the event to schedule.
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: EventScheduler
      Returns true if this scheduler contains no elements. Otherwise false.
      Specified by:
      isEmpty in interface EventScheduler
      Returns:
      true if this scheduler contains no elements. Otherwise false.
    • getNextEventTime

      public long getNextEventTime()
      Description copied from interface: EventScheduler
      Returns the next event time. Make sure the scheduler is not empty.
      Specified by:
      getNextEventTime in interface EventScheduler
      Returns:
      the next event time. Unit: [ns].
    • getScheduledTime

      public long getScheduledTime()
      Description copied from interface: EventScheduler
      Returns the scheduled time.
      Specified by:
      getScheduledTime in interface EventScheduler
      Returns:
      the scheduled time. Unit: [ns].
    • scheduleEvents

      @Nonnull public int scheduleEvents(long time)
      Specified by:
      scheduleEvents in interface EventScheduler
    • getAllEvents

      @Nonnull public Set<Event> getAllEvents()
      Description copied from interface: EventScheduler
      Returns an unmodifiable view of all remaining events.
      Specified by:
      getAllEvents in interface EventScheduler
      Returns:
      all remaining events.