ptolemy.domains.de.kernel
Interface DEEventQueue

All Superinterfaces:
Debuggable
All Known Implementing Classes:
DECQEventQueue

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: DEEventQueue.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Lukito Muliadi, Jie Liu, Haiyang Zheng
See Also:
DEEvent
Accepted Rating:
Green (hyzheng)
Proposed Rating:
Green (hyzheng)

Method Summary
 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.
 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.

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.