Class AsyncEventQueue<E>

java.lang.Object
com.pnfsoftware.jeb.util.collect.AsyncEventQueue<E>
Direct Known Subclasses:
DexDecompilerEventQueue

@Ser public class AsyncEventQueue<E> extends Object
Highly efficient, loosely bounded concurrent pseudo-queue for single-reader/multiple-writers scenarios. The implementation relies on ConcurrentLinkedQueue.

If the bound is reached, newest elements are dropped. To achieve high write efficiency and avoid locking, the queue is loosely bounded: under certain conditions, elements may be dropped although the queue did not reach its capacity; conversely, elements may be added although the queue reached its capacity. To lift this uncertainty, use a bound of Integer.MAX_VALUE. The writers should never never pull elements. Null elements are illegal.

  • Constructor Details

    • AsyncEventQueue

      public AsyncEventQueue()
      Create an unbounded queue.
    • AsyncEventQueue

      public AsyncEventQueue(int capacity)
      Create a queue, optionally bounded.
      Parameters:
      capacity -
  • Method Details

    • add

      public boolean add(E e)
      Add to the tail of the queue.
      Parameters:
      e - non-null entry to be enqueued
      Returns:
      true if the element was added, false if it was dropped
    • pull

      public E pull()
      Pull the head, unless the queue is empty, in which case null is returned.
      Returns:
      the head or null
    • pullAll

      public List<E> pullAll()
      Pull all elements.
      Returns:
    • readAll

      public List<E> readAll()
    • size

      public int size()
    • isEmpty

      public boolean isEmpty()
    • clear

      public void clear()
    • toString

      public String toString()
      Overrides:
      toString in class Object