com.ibm.websphere.samples.asynchbeans.wstrader.tickstream
Class CurrentQueue

java.lang.Object
  extended by com.ibm.websphere.samples.asynchbeans.wstrader.tickstream.CurrentQueue

public class CurrentQueue
extends java.lang.Object

A queue of the most current objects. All old ones drop off the front when the queue gets full. In addition, when the queue is empty, the deQueue method blocks until there are items added to the queue.


Constructor Summary
CurrentQueue(int maxSize)
          Create a queue that can have maxSize elements in it.
 
Method Summary
 void close()
          Close down the queue and stop all blocking
 java.lang.Object deQueue(int timeoutMS)
          Remove an item from the front of the queue.
 void enQueue(java.lang.Object o)
          Add an item to the end of the queue.
 boolean isClosed()
           
 java.lang.Object peekFirst()
          Rreturn the first item from the queue.
 java.lang.Object peekLast()
          Return the last item fromt he queue.
 long size()
          Return the size of the queue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CurrentQueue

public CurrentQueue(int maxSize)
Create a queue that can have maxSize elements in it.

Method Detail

deQueue

public java.lang.Object deQueue(int timeoutMS)
Remove an item from the front of the queue. If the queue is empty, just wait.

Parameters:
timeoutMS - The maximum time to wait.

enQueue

public void enQueue(java.lang.Object o)
Add an item to the end of the queue. If the number of items have reaced maxSize, then remove and item from the front. Wake-up when finished.


peekFirst

public java.lang.Object peekFirst()
Rreturn the first item from the queue.


peekLast

public java.lang.Object peekLast()
Return the last item fromt he queue.


size

public long size()
Return the size of the queue


close

public void close()
Close down the queue and stop all blocking


isClosed

public boolean isClosed()