Class DefaultEventScheduler
java.lang.Object
org.eclipse.mosaic.lib.util.scheduling.DefaultEventScheduler
- All Implemented Interfaces:
EventManager,EventScheduler
- Direct Known Subclasses:
MultiThreadedEventScheduler
The event scheduler implementation is a sequential implementation of the
event scheduler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PriorityQueue<Event>The queue stores and sorts the events.protected longThe last scheduled time. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd anEventto the scheduler.Returns an unmodifiable view of all remaining events.longReturns the next event time.longReturns the scheduled time.booleanisEmpty()Returnstrueif this scheduler contains no elements.intscheduleEvents(long time) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.mosaic.lib.util.scheduling.EventManager
addEvent, newEvent
-
Field Details
-
eventQueue
The queue stores and sorts the events. -
scheduledTime
protected long scheduledTimeThe last scheduled time.
-
-
Constructor Details
-
DefaultEventScheduler
public DefaultEventScheduler()
-
-
Method Details
-
addEvent
Description copied from interface:EventManagerAdd anEventto the scheduler.- Specified by:
addEventin interfaceEventManager- Parameters:
event- the event to schedule.
-
isEmpty
public boolean isEmpty()Description copied from interface:EventSchedulerReturnstrueif this scheduler contains no elements. Otherwisefalse.- Specified by:
isEmptyin interfaceEventScheduler- Returns:
trueif this scheduler contains no elements. Otherwisefalse.
-
getNextEventTime
public long getNextEventTime()Description copied from interface:EventSchedulerReturns the next event time. Make sure the scheduler is not empty.- Specified by:
getNextEventTimein interfaceEventScheduler- Returns:
- the next event time. Unit: [ns].
-
getScheduledTime
public long getScheduledTime()Description copied from interface:EventSchedulerReturns the scheduled time.- Specified by:
getScheduledTimein interfaceEventScheduler- Returns:
- the scheduled time. Unit: [ns].
-
scheduleEvents
@Nonnull public int scheduleEvents(long time) - Specified by:
scheduleEventsin interfaceEventScheduler
-
getAllEvents
Description copied from interface:EventSchedulerReturns an unmodifiable view of all remaining events.- Specified by:
getAllEventsin interfaceEventScheduler- Returns:
- all remaining events.
-