Class ThreadCursoredList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector
-
- org.eclipse.persistence.internal.helper.ThreadCursoredList
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable,java.util.Collection,java.util.List,java.util.RandomAccess
public class ThreadCursoredList extends java.util.VectorSpecial List/Vector subclass that allows concurrent population of the contents while the list is in use. The list will allow iteration while it is still being populated to allow concurrent processing of the contents. Other API such as size that require to full contents know will wait until the list is notified as being complete. This is use to allow the rows and objects of a read-all query to be processed concurrently.- Since:
- OracleAS 10g TopLink (10.0.3)
- Author:
- James Sutherland
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.RuntimeExceptionexceptionUsed to throw exception that occur from the concurrent population thread.protected booleanisCompleteStore if the list is fully populated.
-
Constructor Summary
Constructors Constructor Description ThreadCursoredList()Construct an empty list so that its internal data array has size 10 and its standard capacity increment is zero.ThreadCursoredList(int initialCapacity)Construct an empty list with the specified initial capacity and with its capacity increment equal to zero.ThreadCursoredList(int initialCapacity, int capacityIncrement)Construct an empty list with the specified initial capacity and capacity increment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, java.lang.Object element)Add and notify any waiters that there are new elements.booleanadd(java.lang.Object element)Add and notify any waiters that there are new elements.booleanaddAll(int index, java.util.Collection collection)Add and notify any waiters that there are new elements.booleanaddAll(java.util.Collection collection)Add and notify any waiters that there are new elements.voidaddElement(java.lang.Object object)Add and notify any waiters that there are new elements.voidclear()First wait until complete.java.lang.Objectclone()First wait until complete.booleancontains(java.lang.Object element)If it does not contain the object must wait until it is complete.booleancontainsAll(java.util.Collection collection)If it does not contain the object must wait until it is complete.voidcopyInto(java.lang.Object[] array)First wait until complete.java.lang.ObjectelementAt(int index)If the index is beyond the size wait until complete.java.util.Enumerationelements()Allow concurrent streaming of the elements.booleanequals(java.lang.Object object)First wait until complete.java.lang.ObjectfirstElement()Wait until has an element or is complete.java.lang.Objectget(int index)Wait until has the element or is complete.java.lang.RuntimeExceptiongetException()Return any exception that was throw from concurrent population thread.protected intgetSize()booleanhasException()Return if any exception that was throw from concurrent population thread.inthashCode()First wait until complete.intindexOf(java.lang.Object element)If does not contain the object wait until complete.intindexOf(java.lang.Object element, int index)If does not contain the object wait until complete.voidinsertElementAt(java.lang.Object element, int index)Add the element a notify any waiters that there are new elements.booleanisComplete()Return if the list is complete.booleanisEmpty()If empty wait until an element has been added or is complete.java.util.Iteratoriterator()java.lang.ObjectlastElement()First wait until complete.intlastIndexOf(java.lang.Object element)First wait until complete.intlastIndexOf(java.lang.Object element, int index)First wait until complete.java.util.ListIteratorlistIterator()java.util.ListIteratorlistIterator(int index)Iterate while waiting at end until complete.java.lang.Objectremove(int index)If index is missing wait until is there.booleanremove(java.lang.Object element)If object is missing wait until complete.booleanremoveAll(java.util.Collection collection)First wait until complete.voidremoveAllElements()First wait until complete.booleanremoveElement(java.lang.Object element)If missing wait until complete.voidremoveElementAt(int index)If index is missing wait until reasched or complete.booleanretainAll(java.util.Collection collection)First wait until complete.java.lang.Objectset(int index, java.lang.Object element)If index is missing wait until reached or complete.voidsetElementAt(java.lang.Object element, int index)If index is missing wait until reached or complete.voidsetIsComplete(boolean isComplete)Set the list complete and notify any waiters.intsize()First wait until complete.java.util.ListsubList(int fromIndex, int toIndex)If index is missing wait until reached or complete.voidthrowException(java.lang.RuntimeException exception)Record that the population thread hit an exception, that should be thrown to the processing thread on the next access.java.lang.Object[]toArray()First wait until complete.java.lang.Object[]toArray(java.lang.Object[] array)First wait until complete.java.lang.StringtoString()First wait until complete.voidtrimToSize()First wait until complete.voidwaitUntilAdd()Wait until a new element has been added.voidwaitUntilComplete()Wait until the list has been fully populated.-
Methods inherited from class java.util.Vector
capacity, ensureCapacity, forEach, removeIf, removeRange, replaceAll, setSize, sort, spliterator
-
-
-
-
Constructor Detail
-
ThreadCursoredList
public ThreadCursoredList()
Construct an empty list so that its internal data array has size 10 and its standard capacity increment is zero.
-
ThreadCursoredList
public ThreadCursoredList(int initialCapacity)
Construct an empty list with the specified initial capacity and with its capacity increment equal to zero.
-
ThreadCursoredList
public ThreadCursoredList(int initialCapacity, int capacityIncrement)Construct an empty list with the specified initial capacity and capacity increment.
-
-
Method Detail
-
add
public void add(int index, java.lang.Object element)Add and notify any waiters that there are new elements.- Specified by:
addin interfacejava.util.List- Overrides:
addin classjava.util.Vector
-
add
public boolean add(java.lang.Object element)
Add and notify any waiters that there are new elements.- Specified by:
addin interfacejava.util.Collection- Specified by:
addin interfacejava.util.List- Overrides:
addin classjava.util.Vector
-
addAll
public boolean addAll(int index, java.util.Collection collection)Add and notify any waiters that there are new elements.- Specified by:
addAllin interfacejava.util.List- Overrides:
addAllin classjava.util.Vector
-
addAll
public boolean addAll(java.util.Collection collection)
Add and notify any waiters that there are new elements.- Specified by:
addAllin interfacejava.util.Collection- Specified by:
addAllin interfacejava.util.List- Overrides:
addAllin classjava.util.Vector
-
addElement
public void addElement(java.lang.Object object)
Add and notify any waiters that there are new elements.- Overrides:
addElementin classjava.util.Vector
-
clear
public void clear()
First wait until complete.- Specified by:
clearin interfacejava.util.Collection- Specified by:
clearin interfacejava.util.List- Overrides:
clearin classjava.util.Vector
-
clone
public java.lang.Object clone()
First wait until complete.- Overrides:
clonein classjava.util.Vector
-
hasException
public boolean hasException()
Return if any exception that was throw from concurrent population thread.
-
getException
public java.lang.RuntimeException getException()
Return any exception that was throw from concurrent population thread.
-
throwException
public void throwException(java.lang.RuntimeException exception)
Record that the population thread hit an exception, that should be thrown to the processing thread on the next access. This also records the list and complete.
-
isComplete
public boolean isComplete()
Return if the list is complete. If an exception was thrown during the concurrent population throw the exception.
-
setIsComplete
public void setIsComplete(boolean isComplete)
Set the list complete and notify any waiters.
-
waitUntilComplete
public void waitUntilComplete()
Wait until the list has been fully populated.
-
waitUntilAdd
public void waitUntilAdd()
Wait until a new element has been added.
-
contains
public boolean contains(java.lang.Object element)
If it does not contain the object must wait until it is complete.- Specified by:
containsin interfacejava.util.Collection- Specified by:
containsin interfacejava.util.List- Overrides:
containsin classjava.util.Vector
-
containsAll
public boolean containsAll(java.util.Collection collection)
If it does not contain the object must wait until it is complete.- Specified by:
containsAllin interfacejava.util.Collection- Specified by:
containsAllin interfacejava.util.List- Overrides:
containsAllin classjava.util.Vector
-
copyInto
public void copyInto(java.lang.Object[] array)
First wait until complete.- Overrides:
copyIntoin classjava.util.Vector
-
elementAt
public java.lang.Object elementAt(int index)
If the index is beyond the size wait until complete.- Overrides:
elementAtin classjava.util.Vector
-
getSize
protected int getSize()
-
elements
public java.util.Enumeration elements()
Allow concurrent streaming of the elements.- Overrides:
elementsin classjava.util.Vector
-
equals
public boolean equals(java.lang.Object object)
First wait until complete.- Specified by:
equalsin interfacejava.util.Collection- Specified by:
equalsin interfacejava.util.List- Overrides:
equalsin classjava.util.Vector
-
firstElement
public java.lang.Object firstElement()
Wait until has an element or is complete.- Overrides:
firstElementin classjava.util.Vector
-
get
public java.lang.Object get(int index)
Wait until has the element or is complete.- Specified by:
getin interfacejava.util.List- Overrides:
getin classjava.util.Vector
-
hashCode
public int hashCode()
First wait until complete.- Specified by:
hashCodein interfacejava.util.Collection- Specified by:
hashCodein interfacejava.util.List- Overrides:
hashCodein classjava.util.Vector
-
indexOf
public int indexOf(java.lang.Object element)
If does not contain the object wait until complete.- Specified by:
indexOfin interfacejava.util.List- Overrides:
indexOfin classjava.util.Vector
-
indexOf
public int indexOf(java.lang.Object element, int index)If does not contain the object wait until complete.- Overrides:
indexOfin classjava.util.Vector
-
insertElementAt
public void insertElementAt(java.lang.Object element, int index)Add the element a notify any waiters that there are new elements.- Overrides:
insertElementAtin classjava.util.Vector
-
isEmpty
public boolean isEmpty()
If empty wait until an element has been added or is complete.- Specified by:
isEmptyin interfacejava.util.Collection- Specified by:
isEmptyin interfacejava.util.List- Overrides:
isEmptyin classjava.util.Vector
-
iterator
public java.util.Iterator iterator()
- Specified by:
iteratorin interfacejava.util.Collection- Specified by:
iteratorin interfacejava.lang.Iterable- Specified by:
iteratorin interfacejava.util.List- Overrides:
iteratorin classjava.util.Vector
-
lastElement
public java.lang.Object lastElement()
First wait until complete.- Overrides:
lastElementin classjava.util.Vector
-
lastIndexOf
public int lastIndexOf(java.lang.Object element)
First wait until complete.- Specified by:
lastIndexOfin interfacejava.util.List- Overrides:
lastIndexOfin classjava.util.Vector
-
lastIndexOf
public int lastIndexOf(java.lang.Object element, int index)First wait until complete.- Overrides:
lastIndexOfin classjava.util.Vector
-
listIterator
public java.util.ListIterator listIterator()
- Specified by:
listIteratorin interfacejava.util.List- Overrides:
listIteratorin classjava.util.Vector
-
listIterator
public java.util.ListIterator listIterator(int index)
Iterate while waiting at end until complete.- Specified by:
listIteratorin interfacejava.util.List- Overrides:
listIteratorin classjava.util.Vector
-
remove
public java.lang.Object remove(int index)
If index is missing wait until is there.- Specified by:
removein interfacejava.util.List- Overrides:
removein classjava.util.Vector
-
remove
public boolean remove(java.lang.Object element)
If object is missing wait until complete.- Specified by:
removein interfacejava.util.Collection- Specified by:
removein interfacejava.util.List- Overrides:
removein classjava.util.Vector
-
removeAll
public boolean removeAll(java.util.Collection collection)
First wait until complete.- Specified by:
removeAllin interfacejava.util.Collection- Specified by:
removeAllin interfacejava.util.List- Overrides:
removeAllin classjava.util.Vector
-
removeAllElements
public void removeAllElements()
First wait until complete.- Overrides:
removeAllElementsin classjava.util.Vector
-
removeElement
public boolean removeElement(java.lang.Object element)
If missing wait until complete.- Overrides:
removeElementin classjava.util.Vector
-
removeElementAt
public void removeElementAt(int index)
If index is missing wait until reasched or complete.- Overrides:
removeElementAtin classjava.util.Vector
-
retainAll
public boolean retainAll(java.util.Collection collection)
First wait until complete.- Specified by:
retainAllin interfacejava.util.Collection- Specified by:
retainAllin interfacejava.util.List- Overrides:
retainAllin classjava.util.Vector
-
set
public java.lang.Object set(int index, java.lang.Object element)If index is missing wait until reached or complete.- Specified by:
setin interfacejava.util.List- Overrides:
setin classjava.util.Vector
-
setElementAt
public void setElementAt(java.lang.Object element, int index)If index is missing wait until reached or complete.- Overrides:
setElementAtin classjava.util.Vector
-
size
public int size()
First wait until complete.- Specified by:
sizein interfacejava.util.Collection- Specified by:
sizein interfacejava.util.List- Overrides:
sizein classjava.util.Vector
-
subList
public java.util.List subList(int fromIndex, int toIndex)If index is missing wait until reached or complete.- Specified by:
subListin interfacejava.util.List- Overrides:
subListin classjava.util.Vector
-
toArray
public java.lang.Object[] toArray()
First wait until complete.- Specified by:
toArrayin interfacejava.util.Collection- Specified by:
toArrayin interfacejava.util.List- Overrides:
toArrayin classjava.util.Vector
-
toArray
public java.lang.Object[] toArray(java.lang.Object[] array)
First wait until complete.- Specified by:
toArrayin interfacejava.util.Collection- Specified by:
toArrayin interfacejava.util.List- Overrides:
toArrayin classjava.util.Vector
-
toString
public java.lang.String toString()
First wait until complete.- Overrides:
toStringin classjava.util.Vector
-
trimToSize
public void trimToSize()
First wait until complete.- Overrides:
trimToSizein classjava.util.Vector
-
-