Class ObjectQueue<T>

java.lang.Object
io.sentry.cache.tape.ObjectQueue<T>
All Implemented Interfaces:
Closeable, AutoCloseable, Iterable<T>

@Internal public abstract class ObjectQueue<T> extends Object implements Iterable<T>, Closeable
A queue of objects.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Convert a byte stream to and from a concrete type.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    add(T entry)
    Enqueues an entry that can be processed at any time.
    Returns the entries in the queue as an unmodifiable List.
    void
    Clears this queue.
    static <T> ObjectQueue<T>
    A queue for objects that are atomically and durably serialized to file.
    static <T> ObjectQueue<T>
    An empty queue for objects that is essentially a no-op.
    abstract @Nullable QueueFile
    The underlying QueueFile backing this queue, or null if it's only in memory.
    boolean
    Returns true if this queue contains no entries.
    abstract T
    Returns the head of the queue, or null if the queue is empty.
    peek(int max)
    Reads up to max entries from the head of the queue without removing the entries.
    void
    Removes the head of the queue.
    abstract void
    remove(int n)
    Removes n entries from the head of the queue.
    abstract int
    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.io.Closeable

    close

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Constructor Details

    • ObjectQueue

      public ObjectQueue()
  • Method Details

    • create

      public static <T> ObjectQueue<T> create(QueueFile qf, ObjectQueue.Converter<T> converter)
      A queue for objects that are atomically and durably serialized to file.
    • createEmpty

      public static <T> ObjectQueue<T> createEmpty()
      An empty queue for objects that is essentially a no-op.
    • file

      @Nullable public abstract @Nullable QueueFile file()
      The underlying QueueFile 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()
      Returns true if this queue contains no entries.
    • add

      public abstract void add(T entry) throws IOException
      Enqueues an entry that can be processed at any time.
      Throws:
      IOException
    • peek

      @Nullable public abstract T peek() throws IOException
      Returns the head of the queue, or null if the queue is empty. Does not modify the queue.
      Throws:
      IOException
    • peek

      public List<T> peek(int max) throws IOException
      Reads up to 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.
      Throws:
      IOException
    • asList

      public List<T> asList() throws IOException
      Returns the entries in the queue as an unmodifiable List.
      Throws:
      IOException
    • remove

      public void remove() throws IOException
      Removes the head of the queue.
      Throws:
      IOException
    • remove

      public abstract void remove(int n) throws IOException
      Removes n entries from the head of the queue.
      Throws:
      IOException
    • clear

      public void clear() throws IOException
      Clears this queue. Also truncates the file to the initial size.
      Throws:
      IOException