org.echarts.util
Class FIFOImpl

java.lang.Object
  extended by org.echarts.util.FIFOImpl
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, FIFO

public final class FIFOImpl
extends java.lang.Object
implements FIFO

See Also:
Serialized Form

Field Summary
static int MAXIMUM_NUMBER_OF_ACCEPTOR_REFERENCES
           
 
Fields inherited from interface org.echarts.util.FIFO
serialVersionUID
 
Constructor Summary
FIFOImpl()
           
 
Method Summary
 int addAcceptor(FIFOAcceptor acceptor)
          Adds specified acceptor to this FIFO if not already added, otherwise increments acceptor's reference count.
 void clear()
          Clears queue.
 java.lang.Object get()
          Wait for an element to arrive in FIFO.
 java.lang.Object get(long delay)
          Wait for a specified number of milliseconds for an element to arrive in the FIFO.
 java.lang.Object getNoBlock()
          Get element from queue if one exists without blocking.
 java.util.LinkedList getQueueContents()
          Returns a vector consisting of the current contents of the queue.
 FIFO getRemote()
           
 boolean hasAcceptorReference(FIFOAcceptor acceptor)
          Returns true if this FIFO references the specified acceptor.
 boolean hasAcceptorReferences()
          Returns true if this FIFO references any acceptors.
 boolean isEmpty()
          Returns true if no elements in FIFO, otherwise returns false.
 void put(java.lang.Object o)
          Put a non-null object in the FIFO.
 int removeAcceptor(FIFOAcceptor acceptor)
          Decrements reference count for specified acceptor for this FIFO.
 int size()
          Returns queue size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXIMUM_NUMBER_OF_ACCEPTOR_REFERENCES

public static final int MAXIMUM_NUMBER_OF_ACCEPTOR_REFERENCES
See Also:
Constant Field Values
Constructor Detail

FIFOImpl

public FIFOImpl()
Method Detail

put

public final void put(java.lang.Object o)
               throws java.rmi.RemoteException
Put a non-null object in the FIFO. Operation ignored if object is null. If FIFO is registered with any acceptors, then only threads waiting on acceptors are notified of object's arrival - a thread waiting on get() will not be notified.

Specified by:
put in interface FIFO
Throws:
java.rmi.RemoteException

get

public final java.lang.Object get()
                           throws java.lang.InterruptedException
Wait for an element to arrive in FIFO.

Specified by:
get in interface FIFO
Throws:
java.lang.InterruptedException

getNoBlock

public final java.lang.Object getNoBlock()
Get element from queue if one exists without blocking. If no element exists then return null.

Specified by:
getNoBlock in interface FIFO

get

public final java.lang.Object get(long delay)
                           throws java.lang.InterruptedException
Wait for a specified number of milliseconds for an element to arrive in the FIFO. If an element arrives in the queue before the delay expires, and the element is removed by another thread, then the thread returns without waiting for the additional time. A delay value of 0 will result in the caller blocking until an element arrives in the FIFO. If the call returns before an element can be removed from the FIFO, then a null value is returned.

Specified by:
get in interface FIFO
Throws:
java.lang.InterruptedException

addAcceptor

public final int addAcceptor(FIFOAcceptor acceptor)
Adds specified acceptor to this FIFO if not already added, otherwise increments acceptor's reference count. Returns updated reference count.


removeAcceptor

public final int removeAcceptor(FIFOAcceptor acceptor)
                         throws java.lang.Exception
Decrements reference count for specified acceptor for this FIFO. If reference count decremented to zero then removes acceptor. Throws Exception if acceptor already removed. If last acceptor removed and queue contains elements then notify any thread waiting on get(). Returns updated reference count.

Throws:
java.lang.Exception

hasAcceptorReferences

public final boolean hasAcceptorReferences()
Returns true if this FIFO references any acceptors.


hasAcceptorReference

public final boolean hasAcceptorReference(FIFOAcceptor acceptor)
Returns true if this FIFO references the specified acceptor.


getQueueContents

public final java.util.LinkedList getQueueContents()
Returns a vector consisting of the current contents of the queue.


isEmpty

public final boolean isEmpty()
Returns true if no elements in FIFO, otherwise returns false.


size

public final int size()
Returns queue size.


clear

public final void clear()
Clears queue.


getRemote

public final FIFO getRemote()
                     throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException