Module org.eclipse.persistence.core
Class ThreadCursoredList<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector<E>
-
- org.eclipse.persistence.internal.helper.ThreadCursoredList<E>
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<E>,Collection<E>,List<E>,RandomAccess
public class ThreadCursoredList<E> extends Vector<E>
Special 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 RuntimeExceptionexceptionUsed to throw exception that occur from the concurrent population thread.protected booleanisCompleteStore if the list is fully populated.-
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description ThreadCursoredList()Construct an empty list so that its internal data array has size10and 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, E element)Add and notify any waiters that there are new elements.booleanadd(E element)Add and notify any waiters that there are new elements.booleanaddAll(int index, Collection<? extends E> collection)Add and notify any waiters that there are new elements.booleanaddAll(Collection<? extends E> collection)Add and notify any waiters that there are new elements.voidaddElement(E object)Add and notify any waiters that there are new elements.voidclear()First wait until complete.Objectclone()First wait until complete.booleancontains(Object element)If it does not contain the object must wait until it is complete.booleancontainsAll(Collection<?> collection)If it does not contain the object must wait until it is complete.voidcopyInto(Object[] array)First wait until complete.EelementAt(int index)If the index is beyond the size wait until complete.Enumeration<E>elements()Allow concurrent streaming of the elements.booleanequals(Object object)First wait until complete.EfirstElement()Wait until has an element or is complete.Eget(int index)Wait until has the element or is complete.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(Object element)If does not contain the object wait until complete.intindexOf(Object element, int index)If does not contain the object wait until complete.voidinsertElementAt(E 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.Iterator<E>iterator()ElastElement()First wait until complete.intlastIndexOf(Object element)First wait until complete.intlastIndexOf(Object element, int index)First wait until complete.ListIterator<E>listIterator()ListIterator<E>listIterator(int index)Iterate while waiting at end until complete.Eremove(int index)If index is missing wait until is there.booleanremove(Object element)If object is missing wait until complete.booleanremoveAll(Collection<?> collection)First wait until complete.voidremoveAllElements()First wait until complete.booleanremoveElement(Object element)If missing wait until complete.voidremoveElementAt(int index)If index is missing wait until reasched or complete.booleanretainAll(Collection<?> collection)First wait until complete.Eset(int index, E element)If index is missing wait until reached or complete.voidsetElementAt(E 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.List<E>subList(int fromIndex, int toIndex)If index is missing wait until reached or complete.voidthrowException(RuntimeException exception)Record that the population thread hit an exception, that should be thrown to the processing thread on the next access.Object[]toArray()First wait until complete.<T> T[]toArray(T[] array)First wait until complete.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
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
-
-
-
Field Detail
-
isComplete
protected boolean isComplete
Store if the list is fully populated.
-
exception
protected RuntimeException exception
Used to throw exception that occur from the concurrent population thread.
-
-
Constructor Detail
-
ThreadCursoredList
public ThreadCursoredList()
Construct an empty list so that its internal data array has size10and 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, E element)Add and notify any waiters that there are new elements.
-
add
public boolean add(E element)
Add and notify any waiters that there are new elements.
-
addAll
public boolean addAll(int index, Collection<? extends E> collection)Add and notify any waiters that there are new elements.
-
addAll
public boolean addAll(Collection<? extends E> collection)
Add and notify any waiters that there are new elements.
-
addElement
public void addElement(E object)
Add and notify any waiters that there are new elements.- Overrides:
addElementin classVector<E>
-
clear
public void clear()
First wait until complete.
-
hasException
public boolean hasException()
Return if any exception that was throw from concurrent population thread.
-
getException
public RuntimeException getException()
Return any exception that was throw from concurrent population thread.
-
throwException
public void throwException(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(Object element)
If it does not contain the object must wait until it is complete.
-
containsAll
public boolean containsAll(Collection<?> collection)
If it does not contain the object must wait until it is complete.- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>- Overrides:
containsAllin classVector<E>
-
copyInto
public void copyInto(Object[] array)
First wait until complete.
-
elementAt
public E elementAt(int index)
If the index is beyond the size wait until complete.
-
getSize
protected int getSize()
-
elements
public Enumeration<E> elements()
Allow concurrent streaming of the elements.
-
equals
public boolean equals(Object object)
First wait until complete.
-
firstElement
public E firstElement()
Wait until has an element or is complete.- Overrides:
firstElementin classVector<E>
-
get
public E get(int index)
Wait until has the element or is complete.
-
hashCode
public int hashCode()
First wait until complete.
-
indexOf
public int indexOf(Object element)
If does not contain the object wait until complete.
-
indexOf
public int indexOf(Object element, int index)
If does not contain the object wait until complete.
-
insertElementAt
public void insertElementAt(E element, int index)
Add the element a notify any waiters that there are new elements.- Overrides:
insertElementAtin classVector<E>
-
isEmpty
public boolean isEmpty()
If empty wait until an element has been added or is complete.
-
lastElement
public E lastElement()
First wait until complete.- Overrides:
lastElementin classVector<E>
-
lastIndexOf
public int lastIndexOf(Object element)
First wait until complete.- Specified by:
lastIndexOfin interfaceList<E>- Overrides:
lastIndexOfin classVector<E>
-
lastIndexOf
public int lastIndexOf(Object element, int index)
First wait until complete.- Overrides:
lastIndexOfin classVector<E>
-
listIterator
public ListIterator<E> listIterator()
- Specified by:
listIteratorin interfaceList<E>- Overrides:
listIteratorin classVector<E>
-
listIterator
public ListIterator<E> listIterator(int index)
Iterate while waiting at end until complete.- Specified by:
listIteratorin interfaceList<E>- Overrides:
listIteratorin classVector<E>
-
remove
public E remove(int index)
If index is missing wait until is there.
-
remove
public boolean remove(Object element)
If object is missing wait until complete.
-
removeAll
public boolean removeAll(Collection<?> collection)
First wait until complete.
-
removeAllElements
public void removeAllElements()
First wait until complete.- Overrides:
removeAllElementsin classVector<E>
-
removeElement
public boolean removeElement(Object element)
If missing wait until complete.- Overrides:
removeElementin classVector<E>
-
removeElementAt
public void removeElementAt(int index)
If index is missing wait until reasched or complete.- Overrides:
removeElementAtin classVector<E>
-
retainAll
public boolean retainAll(Collection<?> collection)
First wait until complete.
-
setElementAt
public void setElementAt(E element, int index)
If index is missing wait until reached or complete.- Overrides:
setElementAtin classVector<E>
-
size
public int size()
First wait until complete.
-
subList
public List<E> subList(int fromIndex, int toIndex)
If index is missing wait until reached or complete.
-
toArray
public Object[] toArray()
First wait until complete.
-
toArray
public <T> T[] toArray(T[] array)
First wait until complete.
-
trimToSize
public void trimToSize()
First wait until complete.- Overrides:
trimToSizein classVector<E>
-
-