T - the type of object in this queue.
public class PushPullQueue<T> extends Object
In the future this can be replaced with a SynchronousQueue when this codebase is adapted to Java 1.5. But for Java 1.4 I ended up adapting my own solution.
| Constructor and Description |
|---|
PushPullQueue()
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isEmpty()
|
protected void |
iteratePull()
This method is called during
pull(...).
|
protected void |
iteratePush()
This method is called during
push(...).
|
T |
pull(long timeout)
Pulls an element from the queue.
|
void |
push(T newObject)
This pushes an object on the queue and immediately returns.
|
void |
push(T newObject, long timeout)
This puts on object on the queue, and then blocks until another thread removes it.
|
public boolean isEmpty()
public T pull(long timeout)
timeout - the duration to wait, or a non-positive value if this request should never timeout.
public void push(T newObject)
newObject - the newObject to add to the queue.
public void push(T newObject, long timeout)
newObject - the object to add to the queue.
timeout - the duration to wait, or a non-positive value if this method should never timeout.
protected void iteratePush()
push(...).
Currently this does nothing, but subclasses can override it to abort push operations by throwing a RuntimeException if this operation is aborted.
protected void iteratePull()
pull(...).
Currently this does nothing, but subclasses can override it to abort pull operations by throwing a RuntimeException if this operation is aborted.