Class Queue

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
    Direct Known Subclasses:
    SharedQueue

    public class Queue
    extends Transformer
    This actor implements a queue. When a token is received on the input port, it is stored in the queue. When the trigger port receives a token, the oldest element in the queue is produced on the output. If there is no element in the queue when a token is received on the trigger port, then no output is produced. In this circumstance, if persistentTrigger is true then the next time an input is received, it is sent immediately to the output.

    The inputs can be of any token type, and the output is constrained to be of a type at least that of the input. If the capacity parameter is negative or zero (the default), then the capacity is infinite. Otherwise, the capacity is given by that parameter, and inputs received when the queue is full are discarded. Whenever the size of the queue changes, the new size is produced on the size output port. If an input arrives at the same time that an output is produced, then the size port gets two events at the same time.

    Since:
    Ptolemy II 2.0
    Version:
    $Id$
    Author:
    Steve Neuendorffer and Edward A. Lee
    Pt.AcceptedRating:
    Yellow (eal)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Detail

      • capacity

        public Parameter capacity
        The capacity of the queue. If the value is positive, then it specifies the capacity of the queue. If it is negative or 0, then it specifies that the capacity is infinite. This is an integer with default 0.
      • persistentTrigger

        public Parameter persistentTrigger
        If set to true, then if a trigger arrives when the queue is empty, it is remembered, and the next time an input arrives, it is sent immediately to the output. This is a boolean with default false.
      • size

        public TypedIOPort size
        The current size of the queue. This port produces an output whenever the size changes. It has type int.
      • trigger

        public TypedIOPort trigger
        The trigger port, which has undeclared type. If this port receives a token, then the oldest token in the queue will be emitted on the output port.
      • _queue

        protected FIFOQueue _queue
        The FIFOQueue.
      • _removeTokens

        protected int _removeTokens
        The number of tokens that should be removed from the queue in postfire().
      • _token

        protected Token _token
        Token received in the fire() method for inclusion in the queue in the postfire() method.