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 long
The last scheduled time. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add anEvent
to the scheduler.Returns an unmodifiable view of all remaining events.long
Returns the next event time.long
Returns the scheduled time.boolean
isEmpty()
Returnstrue
if this scheduler contains no elements.int
scheduleEvents
(long time) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:EventManager
Add anEvent
to the scheduler.- Specified by:
addEvent
in interfaceEventManager
- Parameters:
event
- the event to schedule.
-
isEmpty
public boolean isEmpty()Description copied from interface:EventScheduler
Returnstrue
if this scheduler contains no elements. Otherwisefalse
.- Specified by:
isEmpty
in interfaceEventScheduler
- Returns:
true
if this scheduler contains no elements. Otherwisefalse
.
-
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 interfaceEventScheduler
- Returns:
- the next event time. Unit: [ns].
-
getScheduledTime
public long getScheduledTime()Description copied from interface:EventScheduler
Returns the scheduled time.- Specified by:
getScheduledTime
in interfaceEventScheduler
- Returns:
- the scheduled time. Unit: [ns].
-
scheduleEvents
@Nonnull public int scheduleEvents(long time) - Specified by:
scheduleEvents
in interfaceEventScheduler
-
getAllEvents
Description copied from interface:EventScheduler
Returns an unmodifiable view of all remaining events.- Specified by:
getAllEvents
in interfaceEventScheduler
- Returns:
- all remaining events.
-