public class WindowQueue extends Object implements Cloneable
All methods in this class run explicitly or implicitly synchronized on the object.
Most of the methods in this class are also declared final so they can be more readily in-lined by the compiler.
Copyright (c) 2002-2005 webMethods, Inc. This class is based largely on the WindowQueue class
Modifier and Type | Class and Description |
---|---|
static class |
WindowQueue.ShutdownException
The exception to be throw to kick the blocking
get()
call when the queue is shutdown() . |
Constructor and Description |
---|
WindowQueue()
Contructs a windowed queue with a default beginning size.
|
WindowQueue(int size)
Contructs a queue with an initial size.
|
Modifier and Type | Method and Description |
---|---|
protected Object |
clone()
Clones this object.
|
Object |
get()
Gets an object from the queue.
|
Object |
get(int timeoutMs)
Gets an object from the queue.
|
boolean |
isEmpty()
Tests if the queue is empty.
|
boolean |
isFull()
Tests if the queue is full.
|
Object |
peek()
Peeks an object from the queue.
|
void |
put(Object obj)
Adds an object to the queue.
|
void |
shutdown()
Shuts down the queue.
|
public WindowQueue()
public WindowQueue(int size)
size
- the size of the queue, must be > 0. If it is <=0, it is ignored
and the default size is usedprotected Object clone()
public final void put(Object obj)
get()
.
If this call is interrupted/terminated by shutdown()
, the object may be
discarded and the call returns without put it on the queue.
obj
- the Object to add to the queuepublic final Object get() throws WindowQueue.ShutdownException
WindowQueue.ShutdownException
- WindowQueue.ShutdownException
, if this call is interrupted/terminated
by shutdown()
public final Object get(int timeoutMs) throws WindowQueue.ShutdownException
timeoutMs
- - maximum time to wait before returning (null is returned for timeout)WindowQueue.ShutdownException
- WindowQueue.ShutdownException
, if this call is interrupted/terminated
by shutdown()
public final Object peek() throws WindowQueue.ShutdownException
WindowQueue.ShutdownException
- WindowQueue.ShutdownException
, if this call is interrupted/terminated
by shutdown()
public final boolean isFull()
public final boolean isEmpty()
public void shutdown()
put(java.lang.Object)
or get()
which would then abort their current operation.