Package io.perl.api

Interface Queue<T>

All Known Implementing Classes:
AtomicQueue, CQueue, SyncQueue

public interface Queue<T>
A minimal queue abstraction used by PerL to decouple producers and consumers. Implementations may be backed by any concurrent queue or custom ring-buffer.

Contract:

  • poll() should return the next element or null if none is available at the time of the call.
  • add(Object) should enqueue an element and return true on success.
  • clear() should remove any pending elements and reset state.

Thread-safety is implementation-specific; callers should prefer implementations that match their concurrency requirements.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(T data)
    Add data of type T to queue.
    void
    Clear queue and reset internal state.
    Return data of type T from queue, or null if none is available.
  • Method Details

    • poll

      T poll()
      Return data of type T from queue, or null if none is available.
    • add

      boolean add(T data)
      Add data of type T to queue.
      Parameters:
      data - element to add to the queue
      Returns:
      true if the element was added successfully
    • clear

      void clear()
      Clear queue and reset internal state.