Package ptolemy.domains.de.kernel
Class DECQEventQueue
- java.lang.Object
 - 
- ptolemy.domains.de.kernel.DECQEventQueue
 
 
- 
- All Implemented Interfaces:
 DEEventQueue,Debuggable
public class DECQEventQueue extends java.lang.Object implements DEEventQueue
A calendar queue implementation of the DE event queue. This queue stores DE events in the order of their timestamps, microsteps, and then depths of their destination actors. SeeDEEventQueuefor more explanation of the order of DE events.Its complexity is theoretically O(1) for both enqueue and dequeue operations, assuming a reasonable distribution of timestamps. See
CalendarQueue.- Since:
 - Ptolemy II 0.2
 - Version:
 - $Id$
 - Author:
 - Lukito Muliadi, Edward A. Lee, Jie Liu, Haiyang Zheng
 - Pt.AcceptedRating:
 - Green (hyzheng)
 - Pt.ProposedRating:
 - Green (hyzheng)
 
 
- 
- 
Constructor Summary
Constructors Constructor Description DECQEventQueue()Construct an empty event queue.DECQEventQueue(int minBinCount, int binCountFactor, boolean isAdaptive)Construct an empty event queue with the specified parameters. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDebugListener(DebugListener listener)Append a listener to the current set of debug listeners.voidclear()Empty the event queue.DEEventget()Return the earliest DE event in the queue without removing it from the queue.booleanisEmpty()Return true if this event queue is empty.voidput(DEEvent event)Put an event into the event queue.booleanremove(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.voidremoveDebugListener(DebugListener listener)Unregister a debug listener.intsize()Return the size of the event queue.DEEventtake()Dequeue the earliest DE event in this event queue.java.lang.Object[]toArray()Return the events currently in the queue as an array.java.lang.StringtoString()Describe the Contents of the queue as a string. 
 - 
 
- 
- 
Constructor Detail
- 
DECQEventQueue
public DECQEventQueue()
Construct an empty event queue. 
- 
DECQEventQueue
public DECQEventQueue(int minBinCount, int binCountFactor, boolean isAdaptive)Construct an empty event queue with the specified parameters.- Parameters:
 minBinCount- The minimum number of bins.binCountFactor- The factor when changing the bin count.isAdaptive- If the queue changes its number of bins at run time.
 
 - 
 
- 
Method Detail
- 
addDebugListener
public void addDebugListener(DebugListener listener)
Append a listener to the current set of debug listeners.- Specified by:
 addDebugListenerin interfaceDebuggable- Parameters:
 listener- A listener to which to send debug messages.- See Also:
 removeDebugListener(DebugListener)
 
- 
clear
public void clear()
Empty the event queue. This method is synchronized since there may be actors running under different threads in the DE domain.- Specified by:
 clearin interfaceDEEventQueue
 
- 
get
public final DEEvent get()
Return the earliest DE event in the queue without removing it from the queue.- Specified by:
 getin interfaceDEEventQueue- Returns:
 - The earliest DE event in the queue.
 - Throws:
 InvalidStateException- If the queue is empty.
 
- 
isEmpty
public final boolean isEmpty()
Return true if this event queue is empty.- Specified by:
 isEmptyin interfaceDEEventQueue- Returns:
 - True if there are no event in the queue.
 
 
- 
put
public final void put(DEEvent event)
Put an event into the event queue. If the given DE event is not in the event queue, enqueue it into the event queue and notify all threads that are stalled waiting for a DE event to be put in the queue. This method is synchronized since there may be actors running under different threads in the DE domain.- Specified by:
 putin interfaceDEEventQueue- Parameters:
 event- The event to enqueue.
 
- 
remove
public final 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. 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.- Specified by:
 removein interfaceDEEventQueue- Parameters:
 event- The event to enqueue.- Returns:
 - True If a match is found and the entry is removed.
 
 
- 
removeDebugListener
public void removeDebugListener(DebugListener listener)
Unregister a debug listener. If the specified listener has not been previously registered, then do nothing.- Specified by:
 removeDebugListenerin interfaceDebuggable- Parameters:
 listener- The listener to remove from the list of listeners to which debug messages are sent.- See Also:
 addDebugListener(DebugListener)
 
- 
size
public final int size()
Return the size of the event queue.- Specified by:
 sizein interfaceDEEventQueue- Returns:
 - The size of the event queue.
 
 
- 
take
public final DEEvent take()
Dequeue the earliest DE event in this event queue.- Specified by:
 takein interfaceDEEventQueue- Returns:
 - The earliest DE event in the queue.
 - Throws:
 InvalidStateException- If the queue is empty.
 
- 
toArray
public final java.lang.Object[] toArray()
Return the events currently in the queue as an array.- Specified by:
 toArrayin interfaceDEEventQueue- Returns:
 - The events currently in the queue.
 
 
- 
toString
public java.lang.String toString()
Describe the Contents of the queue as a string.- Overrides:
 toStringin classjava.lang.Object- Returns:
 - A string with a comma-separated list of events.
 
 
 - 
 
 -