org.mmbase.util
Class Queue

java.lang.Object
  extended byorg.mmbase.util.Queue

Deprecated. Use edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue, or some other Queue implementation.

public class Queue
extends Object

A list object that allows firstin-firstout retrieval of data. When querying for data that is not (yet) available, the retrieve-process sleeps until it is notified of a change. In 1.5, this class need to be replaced with the java.util.concurrent.BlockingQueue<E> interface.

Version:
$Id: Queue.java,v 1.8 2006/01/16 20:21:42 michiel Exp $
Author:
vpro

Field Summary
 int appendTimeoutTime
          Deprecated. The time to wait until an attempt to append an item times out.
static int DEFAULT_APPEND_TIMEOUT
          Deprecated. Default timeout of 0 for a blocking append call.
static int DEFAULT_GET_TIMEOUT
          Deprecated. Default timeout of 0 for a blocking get call.
static int DEFAULT_QUEUE_SIZE
          Deprecated. Default size of 32 for the queue if none is specified.
 int getTimeoutTime
          Deprecated. The time to wait until an attempt to get an item times out.
 Vector items
          Deprecated.  
 
Constructor Summary
Queue()
          Deprecated. Constructs the queue with the default queue size set to DEFAULT_QUEUE_SIZE, and the append timeout set to DEFAULT_APPEND_TIMEOUT
Queue(int size)
          Deprecated. Constructs the queue, sets the max number of queueable items to the given size, sets the append timeout to DEFAULT_APPEND_TIMEOUT, and sets the get timeout to DEFAULT_GET_TIMEOUT
Queue(int size, int appendTimeout, int getTimeout)
          Deprecated. Constructs the queue, sets the max number of queueable items to the given size, and sets the append() and get() timeouts to the given values.
 
Method Summary
 void append(Object item)
          Deprecated. Appends the given item to the queue.
 void appendTimeout()
          Deprecated. This is called every time we timeout while waiting to append something to the queue.
 int count()
          Deprecated. Returns the number of items currently in the queue.
 Object get()
          Deprecated. Pulls an item off of the queue.
 void getTimeout()
          Deprecated. Pretty much the same thing as the getTimeout() method, but for blocking get() timeouts.
 void newQueue(int size, int appendTimeout, int getTimeout)
          Deprecated. Re-uinitializes the queue, sets the max number of queueable items to the given size, and sets the append() and get() timeouts to the given values.
 int queueSize()
          Deprecated. Returns the size of the queue
 void resize(int newsize)
          Deprecated. Resizes the queue so that it can contain at most the given number of items in it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_QUEUE_SIZE

public static int DEFAULT_QUEUE_SIZE
Deprecated. 
Default size of 32 for the queue if none is specified.


DEFAULT_APPEND_TIMEOUT

public static int DEFAULT_APPEND_TIMEOUT
Deprecated. 
Default timeout of 0 for a blocking append call. Not used


DEFAULT_GET_TIMEOUT

public static int DEFAULT_GET_TIMEOUT
Deprecated. 
Default timeout of 0 for a blocking get call. Not used


appendTimeoutTime

public int appendTimeoutTime
Deprecated. 
The time to wait until an attempt to append an item times out. Not used


getTimeoutTime

public int getTimeoutTime
Deprecated. 
The time to wait until an attempt to get an item times out. Not used


items

public Vector items
Deprecated. 
Constructor Detail

Queue

public Queue()
Deprecated. 
Constructs the queue with the default queue size set to DEFAULT_QUEUE_SIZE, and the append timeout set to DEFAULT_APPEND_TIMEOUT

See Also:
DEFAULT_QUEUE_SIZE, DEFAULT_APPEND_TIMEOUT

Queue

public Queue(int size)
Deprecated. 
Constructs the queue, sets the max number of queueable items to the given size, sets the append timeout to DEFAULT_APPEND_TIMEOUT, and sets the get timeout to DEFAULT_GET_TIMEOUT

Parameters:
size - The maximum size of the queue
See Also:
DEFAULT_APPEND_TIMEOUT

Queue

public Queue(int size,
             int appendTimeout,
             int getTimeout)
Deprecated. 
Constructs the queue, sets the max number of queueable items to the given size, and sets the append() and get() timeouts to the given values.

Parameters:
size - The maximum size of the queue
appendTimeout - If we can't append() within this many milliseconds, the appendTimeout() method is called before retrying.
getTimeout - If we can't get() something within this many milliseconds, the getTimeout() method is called.
See Also:
appendTimeout(), getTimeout()
Method Detail

newQueue

public void newQueue(int size,
                     int appendTimeout,
                     int getTimeout)
Deprecated. 
Re-uinitializes the queue, sets the max number of queueable items to the given size, and sets the append() and get() timeouts to the given values.

Parameters:
size - The maximum size of the queue
appendTimeout - If we can't append() within this many milliseconds, the appendTimeout() method is called before retrying.
getTimeout - If we can't get() something within this many milliseconds, the getTimeout() method is called.

queueSize

public int queueSize()
Deprecated. 
Returns the size of the queue


count

public int count()
Deprecated. 
Returns the number of items currently in the queue.


append

public void append(Object item)
Deprecated. 
Appends the given item to the queue. This method calls a synchronized append method, so that it won't interfere with a get call. The method will block if the queue is full, and it won't block otherwise.

Parameters:
item - The item to be appended to the queue
To Do:
rename to put(), similar to java's BlockingQueue

get

public Object get()
           throws InterruptedException
Deprecated. 
Pulls an item off of the queue. This method will block until something is found. This method is synchronized so it doesn't interfere with the append call.

Returns:
The bottom object of the queue.
Throws:
InterruptedException
To Do:
rename to take(), similar to java's BlockingQueue

appendTimeout

public void appendTimeout()
Deprecated. 
This is called every time we timeout while waiting to append something to the queue. You can use this to figure out if you want to increase the queue size. A real hacker could override this to keep statistics, and use the resize() function to increase the size of the queue after a bunch of timeouts. NOTE - DON'T use the resize() method from within this method - the code will hang forever. You should instead flag another thread to do the resize.

See Also:
appendTimeoutTime

getTimeout

public void getTimeout()
Deprecated. 
Pretty much the same thing as the getTimeout() method, but for blocking get() timeouts. REMEMBER: DON'T call resize() from within this method.

See Also:
getTimeoutTime

resize

public void resize(int newsize)
Deprecated. 
Resizes the queue so that it can contain at most the given number of items in it. Note - the queue may already have more than the given number of items in it, if so, nothing will be allowed in the queue until it shrinks to contain fewer than the new maximum number of elements in it.

Parameters:
newsize - The new maximum size of the queue


MMBase build 1.8.1.20060716