Interface DEEventQueue
-
- All Superinterfaces:
Debuggable
- All Known Implementing Classes:
DECQEventQueue
,MetroIIPtidesListEventQueue
,PtidesListEventQueue
public interface DEEventQueue extends Debuggable
This interface defines an event queue used by DE directors to sort and manage DE events.DE events are sorted according to their timestamps, microsteps, and then the depths of the destination actors. One DE event is said to be earlier than another, if it has a smaller timestamp, or when the timestamps are identical, it has a smaller microstep, or when both time stamps and microsteps are identical, it has a smaller depth. If all three entries are identical, then these two DE events are called identical.
This interface defines a few methods to manage the event queue, including adding a new event into the queue, getting the earliest event of the queue. A correct implementation of this interface should not allow identical events. In particular, when adding a new event, the event is not added if the event is already in the queue. Also note that calling the get() method does not delete events from event queue but calling the take() method does.
- Since:
- Ptolemy II 0.2
- Version:
- $Id$
- Author:
- Lukito Muliadi, Jie Liu, Haiyang Zheng
- See Also:
DEEvent
- Pt.AcceptedRating:
- Green (hyzheng)
- Pt.ProposedRating:
- Green (hyzheng)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Empty this event queue.DEEvent
get()
Return the earliest DE event in this event queue.boolean
isEmpty()
Return true if this event queue is empty.void
put(DEEvent event)
Enqueue a DE event into the event queue.boolean
remove(DEEvent event)
Remove an event from the event queue and return true if it was removed, and false if it was not in the queue.int
size()
Return the size of the event queue.DEEvent
take()
Return the earliest DE event in this event queue.java.lang.Object[]
toArray()
Return the events currently in the queue as an array.-
Methods inherited from interface ptolemy.kernel.util.Debuggable
addDebugListener, removeDebugListener
-
-
-
-
Method Detail
-
clear
void clear()
Empty this event queue.
-
get
DEEvent get() throws InvalidStateException
Return the earliest DE event in this event queue. Note that the DE event is not deleted.- Returns:
- The earliest DE event.
- Throws:
InvalidStateException
- If the event queue is empty.
-
isEmpty
boolean isEmpty()
Return true if this event queue is empty.- Returns:
- True if this queue is empty, false otherwise.
-
put
void put(DEEvent event) throws IllegalActionException
Enqueue a DE event into the event queue. If the event is already contained in the queue, this method does nothing.- Parameters:
event
- The DE event to be put into the queue.- Throws:
IllegalActionException
- If the event cannot be enqueued.
-
remove
boolean remove(DEEvent event) throws IllegalActionException
Remove an event from the event queue and return true if it was removed, and false if it was not in the queue. This should only be used for pure events (consequences of fireAt()), not for events carrying payloads, because this does not remove the payload from the DEReceiver. The event passed is an argument need not be exactly the same event in the queue. It just has to match the actor, timeStamp, microstep, and depth of the event to be removed. Implementation of this method is optional.- Parameters:
event
- The event to enqueue.- Returns:
- True If a match is found and the entry is removed.
- Throws:
IllegalActionException
- If the method is not supported.
-
size
int size()
Return the size of the event queue.- Returns:
- The size of the event queue.
-
take
DEEvent take() throws InvalidStateException
Return the earliest DE event in this event queue. The returned event is deleted from the event queue.- Returns:
- The earliest DE event in the event queue.
- Throws:
InvalidStateException
- If the queue is empty.
-
toArray
java.lang.Object[] toArray()
Return the events currently in the queue as an array.- Returns:
- The events currently in the queue.
-
-