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 Summary
Fields Modifier and Type Field Description protected PriorityQueue<Event>
eventQueue
The queue stores and sorts the events.protected long
scheduledTime
The last scheduled time.
-
Constructor Summary
Constructors Constructor Description DefaultEventScheduler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEvent(Event event)
Add anEvent
to the scheduler.Set<Event>
getAllEvents()
Returns an unmodifiable view of all remaining events.long
getNextEventTime()
Returns the next event time.long
getScheduledTime()
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 Detail
-
eventQueue
protected final PriorityQueue<Event> eventQueue
The queue stores and sorts the events.
-
scheduledTime
protected long scheduledTime
The last scheduled time.
-
-
Method Detail
-
addEvent
public void addEvent(@Nonnull Event event)
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
@Nonnull public Set<Event> getAllEvents()
Description copied from interface:EventScheduler
Returns an unmodifiable view of all remaining events.- Specified by:
getAllEvents
in interfaceEventScheduler
- Returns:
- all remaining events.
-
-