Class Buffer

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

    public class Buffer
    extends TypedAtomicActor
    This actor buffers data provided at the input, sending it to the output when needed. It uses two threads. The main actor thread is willing to rendezvous with the output as long as the buffer is not empty. A second thread is created on the first invocation of fire(). This second thread is willing to rendezvous with the input as long as the buffer is not full. Thus, this actor acts as a FIFO (first-in, first-out) buffer that will accept input tokens as long as it is not full, and will produce output tokens as long as it is not empty.

    If the capacity changes during execution, and the buffer already contains more tokens than the new capacity, then no tokens are lost, but no new tokens are accepted at the input until the number of buffered tokens drops below the capacity.

    This actor is similar to the ResourcePool actor except that the input and output ports are not multiports and there are no initial tokens in this buffer.

    Since:
    Ptolemy II 5.1
    Version:
    $Id$
    Author:
    Edward A. Lee
    See Also:
    ResourcePool
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Yellow (eal)