Package ej.bon

## Class ReferenceQueue<T>

- java.lang.Object
- - ej.bon.ReferenceQueue<T>

- Type Parameters:
    `T` - the type of enqueued objects

      public final class ReferenceQueue<T>
      extends Object

  ReferenceQueue represents a queue of EnqueuedWeakReference. The system is responsible for adding such EnqueuedWeakReference into the ReferenceQueue.

  There are two ways to retrieve and remove an element from the queue.

  - `poll()` : returns null if the queue is empty, otherwise returns and removes the first element of the FIFO queue.
  - `remove()` : blocks the current thread until the queue becomes not empty. returns and removes the first element of the FIFO queue.
  See Also:
    `EnqueuedWeakReference`

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ReferenceQueue()` | Creates an empty `Reference` queue.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `EnqueuedWeakReference<T>` | `poll()` | Queries the queue and returns and removes the first element of the queue.
    `EnqueuedWeakReference<T>` | `remove()` | Queries the queue, returns and removes the first element of the queue.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ReferenceQueue

          public ReferenceQueue()

      Creates an empty `Reference` queue.

  - ### Method Detail

    - #### poll

          @Nullable
          public EnqueuedWeakReference<T> poll()

      Queries the queue and returns and removes the first element of the queue. If the queue is empty, returns `null`.
      Returns:
        EnqueuedWeakReference or `null`

    - #### remove

          public EnqueuedWeakReference<T> remove()
                                          throws InterruptedException

      Queries the queue, returns and removes the first element of the queue. If the queue is empty, blocks the current thread until the queue gets at least one element (automatically added by the system).
      Returns:
        EnqueuedWeakReference
      Throws:
        `InterruptedException` - if the thread is interrupted