ManagedConcurrentLinkedQueue (Groovy 5.0.0)
Description: declaration: package: org.codehaus.groovy.util, class: ManagedConcurrentLinkedQueue

Package org.codehaus.groovy.util

# Class ManagedConcurrentLinkedQueue<T>

java.lang.Object
org.codehaus.groovy.util.ManagedConcurrentLinkedQueue<T>

Type Parameters:
  `T` - the type of values to store

All Implemented Interfaces:
  `Iterable<T>`

public class ManagedConcurrentLinkedQueue<T> extends Object implements Iterable<T>
A queue that stores values wrapped in a Reference, the type of which is determined by the provided `ReferenceBundle`. References stored in this queue will be removed when reference processing occurs.

This queue is backed by a `ConcurrentLinkedQueue` and is thread safe. The iterator will only return non-null values (reachable) and is based on the "weakly consistent" iterator of the underlying `ConcurrentLinkedQueue`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ManagedConcurrentLinkedQueue(ReferenceBundle bundle)`
  Creates an empty ManagedConcurrentLinkedQueue that will use the provided `ReferenceBundle` to store values as the given Reference type.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(T value)`
  Adds the specified value to the queue.
  `boolean`
  `isEmpty()`
  Returns `true` if this queue contains no elements.
  `Iterator<T>`
  `iterator()`
  Returns an iterator over all non-null values in this queue.
  `T[]`
  `toArray(T[] tArray)`
  Returns an array containing all values from this queue in the sequence they were added.
  `List<T>`
  `values()`
  Returns a list containing all values from this queue in the sequence they were added.

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

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

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Constructor Details

  - ### ManagedConcurrentLinkedQueue

    public ManagedConcurrentLinkedQueue(ReferenceBundle bundle)
    Creates an empty ManagedConcurrentLinkedQueue that will use the provided `ReferenceBundle` to store values as the given Reference type.
    Parameters:
      `bundle` - used to create the appropriate Reference type for the values stored

- ## Method Details

  - ### add

    public void add(T value)
    Adds the specified value to the queue.
    Parameters:
      `value` - the value to add

  - ### isEmpty

    public boolean isEmpty()
    Returns `true` if this queue contains no elements.

    This method does not check the elements to verify they contain non-null reference values.

  - ### toArray

    public T[] toArray(T[] tArray)
    Returns an array containing all values from this queue in the sequence they were added.
    Parameters:
      `tArray` - the array to populate if big enough, else a new array with the same runtime type
    Returns:
      an array containing all non-null values in this queue

  - ### values

    public List<T> values()
    Returns a list containing all values from this queue in the sequence they were added.

  - ### iterator

    public Iterator<T> iterator()
    Returns an iterator over all non-null values in this queue. The values should be returned in the order they were added.
    Specified by:
      `iterator` in interface `Iterable<T>`