com.mindbright.util
public final class Queue extends java.lang.Object
Constructor and Description |
---|
Queue()
Constructs a new queue with the default depth (64) and hiwater
(32) levels.
|
Queue(int depth,
int hiwater)
Constructs a new queue with custom depth and hiwater levels.
|
Modifier and Type | Method and Description |
---|---|
void |
disable()
Disable the queue.
|
void |
enable()
Enable a disabled queue.
|
java.lang.Object |
getFirst()
Get the first object on the queue.
|
java.lang.Object |
getFirst(long ms)
Get the first object on the queue, optionally with a timeout.
|
boolean |
isEmpty()
Check if the queue is empty
|
void |
putFirst(java.lang.Object obj)
insert an object at the head of the queue.
|
void |
putLast(java.lang.Object obj)
Append an object to the queue.
|
void |
release()
Release any blocked object.
|
void |
setBlocking(boolean block)
Controls if the getFirst call should block.
|
public Queue()
public Queue(int depth, int hiwater)
public void putLast(java.lang.Object obj)
obj
- the object to appendpublic void putFirst(java.lang.Object obj)
obj
- the object to insertpublic void release()
public void disable()
public void enable()
public void setBlocking(boolean block)
block
- true if calls to getFirst should blockpublic boolean isEmpty()
public java.lang.Object getFirst(long ms)
ms
- how long, in milliseconds, to wait, if the queue is
blocking, for a new object.public java.lang.Object getFirst()