ariba.util.core
Class ThreadedQueue

java.lang.Object
  extended by ariba.util.core.ThreadedQueue

public class ThreadedQueue
extends java.lang.Object

This is a ThreadedQueue used for a producer/consumer model of threads. Order out is guranteed to be the same as the order in. If maxItems is specified, there will never be more than maxItems pending in the queue, if the max number are already present, the producer will block until items are consumed.


Constructor Summary
ThreadedQueue()
          Create a threaded queue with an unbounded number of elements.
ThreadedQueue(int maxItems)
           
 
Method Summary
 int count()
          Determine how many items are in the queue
 java.lang.Object error()
          Called by either side to test for error; generally called by producer one time after all consumer threads die to test for errors occuring after its last insertObject and before consumer threads are done
 void incrementUseCount()
           
 java.lang.Object insertObject(java.lang.Object o)
          Called by producer.
 boolean isEmpty()
          Called by producer.
 boolean moreData()
          Called by producer.
 java.lang.Object nextObject()
          Called by consumer.
 java.lang.Object peekNextObject()
          Called by consumer.
 void setError(java.lang.Object o)
          Called by either side to set an error
 void setMaxItems(int maxItems)
           
 void setNoMoreData()
          Called by producer.
 void waitForEmpty()
          Called by producer; useful when waiting to flush queue before continuing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadedQueue

public ThreadedQueue(int maxItems)

ThreadedQueue

public ThreadedQueue()
Create a threaded queue with an unbounded number of elements.

Method Detail

setMaxItems

public void setMaxItems(int maxItems)

insertObject

public java.lang.Object insertObject(java.lang.Object o)
Called by producer. If there was an error on the consumer end, it will return it. Do not, under any circumstances, put a Log message in this method. It will cause an infinite recursion.


incrementUseCount

public void incrementUseCount()

setError

public void setError(java.lang.Object o)
Called by either side to set an error


error

public java.lang.Object error()
Called by either side to test for error; generally called by producer one time after all consumer threads die to test for errors occuring after its last insertObject and before consumer threads are done


isEmpty

public boolean isEmpty()
Called by producer.


count

public int count()
Determine how many items are in the queue


moreData

public boolean moreData()
Called by producer.


waitForEmpty

public void waitForEmpty()
Called by producer; useful when waiting to flush queue before continuing.


setNoMoreData

public void setNoMoreData()
Called by producer.


peekNextObject

public java.lang.Object peekNextObject()
Called by consumer.


nextObject

public java.lang.Object nextObject()
Called by consumer.



AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.