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 interfaceConvert a byte stream to and from a concrete type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidEnqueues an entry that can be processed at any time.asList()Returns the entries in the queue as an unmodifiableList.voidclear()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 QueueFilefile()The underlyingQueueFilebacking this queue, or null if it's only in memory.booleanisEmpty()Returnstrueif this queue contains no entries.abstract Tpeek()Returns the head of the queue, ornullif the queue is empty.peek(int max) Reads up tomaxentries from the head of the queue without removing the entries.voidremove()Removes the head of the queue.abstract voidremove(int n) Removesnentries from the head of the queue.abstract intsize()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, waitMethods 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 underlyingQueueFilebacking 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()Returnstrueif 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, ornullif the queue is empty. Does not modify the queue.- Throws:
IOException
-
peek
Reads up tomaxentries from the head of the queue without removing the entries. If the queue'ssize()is less thanmaxthen 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
Removesnentries from the head of the queue.- Throws:
IOException
-
clear
Clears this queue. Also truncates the file to the initial size.- Throws:
IOException
-