Top Description Inners Fields Constructors Methods
org.codehaus.groovy.util

public Class ManagedConcurrentLinkedQueue<T>

extends Object
implements Iterable<T>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Type Parameters
<T>
the type of values to store
Imports
java.util.ArrayList, .Iterator, .List, .NoSuchElementException, java.util.concurrent.ConcurrentLinkedQueue

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class

Field Summary

Modifier and TypeField and Description
private final ReferenceBundle
private final ConcurrentLinkedQueue<ManagedConcurrentLinkedQueue<T>.Element<T>>

Constructor Summary

AccessConstructor and Description
public
ManagedConcurrentLinkedQueue(ReferenceBundle
used to create the appropriate Reference type for the values stored
bundle
)

Creates an empty ManagedConcurrentLinkedQueue that will use the provided ReferenceBundle to store values as the given Reference type.

Method Summary

Modifier and TypeMethod and Description
public void
add(T
the value to add
value
)

Adds the specified value to the queue.

public boolean
isEmpty()

Returns true if this queue contains no elements.

public Iterator<T>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over all non-null values in this queue.
public T[]

Returns:

an array containing all non-null values in this queue
toArray
(T[]
the array to populate if big enough, else a new array with the same runtime type
tArray
)

Returns an array containing all values from this queue in the sequence they were added.

public List<T>
values()

Returns a list containing all values from this queue in the sequence they were added.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bundleback to summary
private final ReferenceBundle bundle
queueback to summary
private final ConcurrentLinkedQueue<ManagedConcurrentLinkedQueue<T>.Element<T>> queue

Constructor Detail

ManagedConcurrentLinkedQueueback to summary
public ManagedConcurrentLinkedQueue(ReferenceBundle bundle)

Creates an empty ManagedConcurrentLinkedQueue that will use the provided ReferenceBundle to store values as the given Reference type.

Parameters
bundle:ReferenceBundle

used to create the appropriate Reference type for the values stored

Method Detail

addback to summary
public void add(T value)

Adds the specified value to the queue.

Parameters
value:T

the value to add

isEmptyback to summary
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.

iteratorback to summary
public Iterator<T> iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over all non-null values in this queue. The values should be returned in the order they were added.

Returns:Iterator<T>

Doc from java.lang.Iterable.iterator.

an Iterator.

Annotations
@Override
toArrayback to summary
public T[] toArray(T[] tArray)

Returns an array containing all values from this queue in the sequence they were added.

Parameters
tArray:T[]

the array to populate if big enough, else a new array with the same runtime type

Returns:T[]

an array containing all non-null values in this queue

valuesback to summary
public List<T> values()

Returns a list containing all values from this queue in the sequence they were added.

org.codehaus.groovy.util back to summary

private Class ManagedConcurrentLinkedQueue.Element<V>

extends ManagedReference<V>
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv
Element(V value)

Method Summary

Modifier and TypeMethod and Description
public void
Inherited from org.codehaus.groovy.util.ManagedReference:
clearget

Constructor Detail

Elementback to summary
pack-priv Element(V value)

Method Detail

finalizeReferenceback to summary
public void finalizeReference()

Overrides org.codehaus.groovy.util.ManagedReference.finalizeReference.

Implements org.codehaus.groovy.util.Finalizable.finalizeReference.

Annotations
@Override
org.codehaus.groovy.util back to summary

private Class ManagedConcurrentLinkedQueue.Itr

extends Object
implements Iterator<T>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
pack-priv ManagedConcurrentLinkedQueue<T>.Element<T>
pack-priv boolean
pack-priv T
pack-priv final Iterator<ManagedConcurrentLinkedQueue<T>.Element<T>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public T
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
pack-priv ManagedConcurrentLinkedQueue<T>.Element<T> current
exhaustedback to summary
pack-priv boolean exhausted
valueback to summary
pack-priv T value
wrappedback to summary
pack-priv final Iterator<ManagedConcurrentLinkedQueue<T>.Element<T>> wrapped

Constructor Detail

Itrback to summary
pack-priv Itr(Iterator<ManagedConcurrentLinkedQueue<T>.Element<T>> wrapped)

Method Detail

advanceback to summary
private void advance()
hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public T next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:T

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override