public abstract class ObjectQueue<T>
extends java.lang.Object
implements java.lang.Iterable<T>, java.io.Closeable
| Modifier and Type | Class and Description |
|---|---|
static interface |
ObjectQueue.Converter<T>
Convert a byte stream to and from a concrete type.
|
| Constructor and Description |
|---|
ObjectQueue() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
add(T entry)
Enqueues an entry that can be processed at any time.
|
java.util.List<T> |
asList()
Returns the entries in the queue as an unmodifiable
List. |
void |
clear()
Clears this queue.
|
static <T> ObjectQueue<T> |
create(QueueFile qf,
ObjectQueue.Converter<T> converter)
A queue for objects that are atomically and durably serialized to
file. |
static <T> ObjectQueue<T> |
createInMemory()
A queue for objects that are not serious enough to be written to disk.
|
abstract QueueFile |
file()
The underlying
QueueFile backing this queue, or null if it's only in memory. |
boolean |
isEmpty()
Returns
true if this queue contains no entries. |
abstract T |
peek()
Returns the head of the queue, or
null if the queue is empty. |
java.util.List<T> |
peek(int max)
Reads up to
max entries from the head of the queue without removing the entries. |
void |
remove()
Removes the head of the queue.
|
abstract void |
remove(int n)
Removes
n entries from the head of the queue. |
abstract int |
size()
Returns the number of entries in the queue.
|
public static <T> ObjectQueue<T> create(QueueFile qf, ObjectQueue.Converter<T> converter)
file.public static <T> ObjectQueue<T> createInMemory()
@Nullable public abstract QueueFile file()
QueueFile backing this queue, or null if it's only in memory.public abstract int size()
public boolean isEmpty()
true if this queue contains no entries.public abstract void add(T entry) throws java.io.IOException
java.io.IOException@Nullable public abstract T peek() throws java.io.IOException
null if the queue is empty. Does not modify the
queue.java.io.IOExceptionpublic java.util.List<T> peek(int max) throws java.io.IOException
max entries from the head of the queue without removing the entries.
If the queue's size() is less than max then only size() entries
are read.java.io.IOExceptionpublic java.util.List<T> asList() throws java.io.IOException
List.java.io.IOExceptionpublic void remove()
throws java.io.IOException
java.io.IOExceptionpublic abstract void remove(int n)
throws java.io.IOException
n entries from the head of the queue.java.io.IOExceptionpublic void clear()
throws java.io.IOException
java.io.IOException