Package io.sentry.cache.tape
Class ObjectQueue<T>
java.lang.Object
io.sentry.cache.tape.ObjectQueue<T>
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<T>
A queue of objects.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Convert a byte stream to and from a concrete type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
Enqueues an entry that can be processed at any time.asList()
Returns the entries in the queue as an unmodifiableList
.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 tofile
.static <T> ObjectQueue<T>
An empty queue for objects that is essentially a no-op.abstract @Nullable QueueFile
file()
The underlyingQueueFile
backing this queue, or null if it's only in memory.boolean
isEmpty()
Returnstrue
if this queue contains no entries.abstract T
peek()
Returns the head of the queue, ornull
if the queue is empty.peek
(int max) Reads up tomax
entries from the head of the queue without removing the entries.void
remove()
Removes the head of the queue.abstract void
remove
(int n) Removesn
entries from the head of the queue.abstract int
size()
Returns the number of entries in the queue.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Constructor Details
-
ObjectQueue
public ObjectQueue()
-
-
Method Details
-
create
A queue for objects that are atomically and durably serialized tofile
. -
createEmpty
An empty queue for objects that is essentially a no-op. -
file
The underlyingQueueFile
backing this queue, or null if it's only in memory. -
size
public abstract int size()Returns the number of entries in the queue. -
isEmpty
public boolean isEmpty()Returnstrue
if this queue contains no entries. -
add
Enqueues an entry that can be processed at any time.- Throws:
IOException
-
peek
Returns the head of the queue, ornull
if the queue is empty. Does not modify the queue.- Throws:
IOException
-
peek
Reads up tomax
entries from the head of the queue without removing the entries. If the queue'ssize()
is less thanmax
then onlysize()
entries are read.- Throws:
IOException
-
asList
Returns the entries in the queue as an unmodifiableList
.- Throws:
IOException
-
remove
Removes the head of the queue.- Throws:
IOException
-
remove
Removesn
entries from the head of the queue.- Throws:
IOException
-
clear
Clears this queue. Also truncates the file to the initial size.- Throws:
IOException
-