ptolemy.domains.ci.kernel
Class CIReceiver

java.lang.Object
  extended by ptolemy.actor.AbstractReceiver
      extended by ptolemy.domains.ci.kernel.CIReceiver
All Implemented Interfaces:
Receiver

public class CIReceiver
extends AbstractReceiver

An implementation of the ptolemy.actor.Receiver interface for the CI domain. This receiver provides a FIFO buffer between an active actor and an inactive actor or two inactive actors. When an active actor with push output puts a token in a receiver, the inactive actor that reads from the receiver will be put in the task queue of the director. When the director fires an inactive actor, the actors that receive data from this actor are executed as data-driven. For an active actor with pull input, its actor manager will be notified when an input token arrives, and will continue to iterate the actor.

Since:
Ptolemy II 3.0
Version:
$Id: CIReceiver.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Xiaojun Liu, Yang Zhao
Accepted Rating:
Red (liuxj)
Proposed Rating:
Yellow (liuxj)

Field Summary
private  Actor _actor
           
private  CIDirector _director
           
private  boolean _initialized
           
private  boolean _isAsyncPullSink
           
private  boolean _isAsyncPushSink
           
private  boolean _isPush
           
private  java.util.LinkedList<Token> _tokens
           
 
Constructor Summary
CIReceiver(CIDirector director)
          Construct an empty receiver.
 
Method Summary
private  void _initialize()
           
private  void _notify()
           
 void clear()
          Clear this receiver.
 Token get()
          Get a token from this receiver.
 boolean hasRoom()
          Return true.
 boolean hasRoom(int numberOfTokens)
          Return true if the receiver has room to put the specified number of tokens into it (via the put() method).
 boolean hasToken()
          Return true if the receiver contains a token that can be obtained by calling the get() method.
 boolean hasToken(int numberOfTokens)
          Return true if the receiver contains the specified number of tokens.
 void put(Token token)
          Put the specified token into this receiver.
 void putArray(Token[] tokenArray, int numberOfTokens)
          Put a portion of the specified token array into this receiver.
 
Methods inherited from class ptolemy.actor.AbstractReceiver
elementList, getArray, getContainer, getCurrentTime, getModelTime, isKnown, putArrayToAll, putToAll, reset, setContainer, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_director

private CIDirector _director

_actor

private Actor _actor

_tokens

private java.util.LinkedList<Token> _tokens

_initialized

private boolean _initialized

_isAsyncPushSink

private boolean _isAsyncPushSink

_isAsyncPullSink

private boolean _isAsyncPullSink

_isPush

private boolean _isPush
Constructor Detail

CIReceiver

public CIReceiver(CIDirector director)
Construct an empty receiver.

Parameters:
director - The director that creates this receiver.
Method Detail

clear

public void clear()
Clear this receiver.

Specified by:
clear in interface Receiver
Overrides:
clear in class AbstractReceiver

get

public Token get()
          throws NoTokenException
Get a token from this receiver.

Specified by:
get in interface Receiver
Specified by:
get in class AbstractReceiver
Returns:
A token from this receiver.
Throws:
NoTokenException - If there is no token.

hasRoom

public boolean hasRoom()
Return true. The receiver acts as an infinite FIFO buffer.

Specified by:
hasRoom in interface Receiver
Specified by:
hasRoom in class AbstractReceiver
Returns:
True if the next call to put() will not result in a NoRoomException.

hasRoom

public boolean hasRoom(int numberOfTokens)
Return true if the receiver has room to put the specified number of tokens into it (via the put() method). Returning true in this method guarantees that the next numberOfTokens calls to put() or a corresponding call to putArray() will not result in an exception.

Specified by:
hasRoom in interface Receiver
Specified by:
hasRoom in class AbstractReceiver
Parameters:
numberOfTokens - The number of tokens to put into this receiver.
Returns:
True if the next numberOfTokens calls to put() will not result in a NoRoomException.

hasToken

public boolean hasToken()
Return true if the receiver contains a token that can be obtained by calling the get() method.

Specified by:
hasToken in interface Receiver
Specified by:
hasToken in class AbstractReceiver
Returns:
True if the next call to get() will not result in a NoTokenException.

hasToken

public boolean hasToken(int numberOfTokens)
Return true if the receiver contains the specified number of tokens. In an implementation, returning true in this method guarantees that the next numberOfTokens calls to get(), or a corresponding call to getArray(), will not result in an exception.

Specified by:
hasToken in interface Receiver
Specified by:
hasToken in class AbstractReceiver
Parameters:
numberOfTokens - The number of tokens desired.
Returns:
True if the next numberOfTokens calls to get() will not result in a NoTokenException.

put

public void put(Token token)
         throws NoRoomException
Put the specified token into this receiver.

Specified by:
put in interface Receiver
Specified by:
put in class AbstractReceiver
Parameters:
token - The token to put into the receiver, or null to put no token.
Throws:
NoRoomException - If there is no room in the receiver.

putArray

public void putArray(Token[] tokenArray,
                     int numberOfTokens)
              throws NoRoomException
Put a portion of the specified token array into this receiver. The first numberOfTokens elements of the token array are put into this receiver.

Specified by:
putArray in interface Receiver
Overrides:
putArray in class AbstractReceiver
Parameters:
tokenArray - The array containing tokens to put into this receiver.
numberOfTokens - The number of elements of the token array to put into this receiver.
Throws:
NoRoomException - If the token array cannot be put.

_initialize

private void _initialize()
                  throws IllegalActionException
Throws:
IllegalActionException

_notify

private void _notify()