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:
Serializable
,Cloneable
,Iterable
,Collection
,List
,RandomAccess
public class ThreadCursoredList extends Vector
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 RuntimeException
exception
Used to throw exception that occur from the concurrent population thread.protected boolean
isComplete
Store 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 size10
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 void
add(int index, Object element)
Add and notify any waiters that there are new elements.boolean
add(Object element)
Add and notify any waiters that there are new elements.boolean
addAll(int index, Collection collection)
Add and notify any waiters that there are new elements.boolean
addAll(Collection collection)
Add and notify any waiters that there are new elements.void
addElement(Object object)
Add and notify any waiters that there are new elements.void
clear()
First wait until complete.Object
clone()
First wait until complete.boolean
contains(Object element)
If it does not contain the object must wait until it is complete.boolean
containsAll(Collection collection)
If it does not contain the object must wait until it is complete.void
copyInto(Object[] array)
First wait until complete.Object
elementAt(int index)
If the index is beyond the size wait until complete.Enumeration
elements()
Allow concurrent streaming of the elements.boolean
equals(Object object)
First wait until complete.Object
firstElement()
Wait until has an element or is complete.Object
get(int index)
Wait until has the element or is complete.RuntimeException
getException()
Return any exception that was throw from concurrent population thread.protected int
getSize()
boolean
hasException()
Return if any exception that was throw from concurrent population thread.int
hashCode()
First wait until complete.int
indexOf(Object element)
If does not contain the object wait until complete.int
indexOf(Object element, int index)
If does not contain the object wait until complete.void
insertElementAt(Object element, int index)
Add the element a notify any waiters that there are new elements.boolean
isComplete()
Return if the list is complete.boolean
isEmpty()
If empty wait until an element has been added or is complete.Iterator
iterator()
Object
lastElement()
First wait until complete.int
lastIndexOf(Object element)
First wait until complete.int
lastIndexOf(Object element, int index)
First wait until complete.ListIterator
listIterator()
ListIterator
listIterator(int index)
Iterate while waiting at end until complete.Object
remove(int index)
If index is missing wait until is there.boolean
remove(Object element)
If object is missing wait until complete.boolean
removeAll(Collection collection)
First wait until complete.void
removeAllElements()
First wait until complete.boolean
removeElement(Object element)
If missing wait until complete.void
removeElementAt(int index)
If index is missing wait until reasched or complete.boolean
retainAll(Collection collection)
First wait until complete.Object
set(int index, Object element)
If index is missing wait until reached or complete.void
setElementAt(Object element, int index)
If index is missing wait until reached or complete.void
setIsComplete(boolean isComplete)
Set the list complete and notify any waiters.int
size()
First wait until complete.List
subList(int fromIndex, int toIndex)
If index is missing wait until reached or complete.void
throwException(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.Object[]
toArray(Object[] array)
First wait until complete.String
toString()
First wait until complete.void
trimToSize()
First wait until complete.void
waitUntilAdd()
Wait until a new element has been added.void
waitUntilComplete()
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
-
-
-
-
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 size10
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, Object element)
Add and notify any waiters that there are new elements.
-
add
public boolean add(Object element)
Add and notify any waiters that there are new elements.
-
addAll
public boolean addAll(int index, Collection collection)
Add and notify any waiters that there are new elements.
-
addAll
public boolean addAll(Collection collection)
Add and notify any waiters that there are new elements.
-
addElement
public void addElement(Object object)
Add and notify any waiters that there are new elements.- Overrides:
addElement
in classVector
-
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:
containsAll
in interfaceCollection
- Specified by:
containsAll
in interfaceList
- Overrides:
containsAll
in classVector
-
copyInto
public void copyInto(Object[] array)
First wait until complete.
-
elementAt
public Object elementAt(int index)
If the index is beyond the size wait until complete.
-
getSize
protected int getSize()
-
elements
public Enumeration elements()
Allow concurrent streaming of the elements.
-
equals
public boolean equals(Object object)
First wait until complete.
-
firstElement
public Object firstElement()
Wait until has an element or is complete.- Overrides:
firstElement
in classVector
-
get
public Object 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(Object element, int index)
Add the element a notify any waiters that there are new elements.- Overrides:
insertElementAt
in classVector
-
isEmpty
public boolean isEmpty()
If empty wait until an element has been added or is complete.
-
iterator
public Iterator iterator()
-
lastElement
public Object lastElement()
First wait until complete.- Overrides:
lastElement
in classVector
-
lastIndexOf
public int lastIndexOf(Object element)
First wait until complete.- Specified by:
lastIndexOf
in interfaceList
- Overrides:
lastIndexOf
in classVector
-
lastIndexOf
public int lastIndexOf(Object element, int index)
First wait until complete.- Overrides:
lastIndexOf
in classVector
-
listIterator
public ListIterator listIterator()
- Specified by:
listIterator
in interfaceList
- Overrides:
listIterator
in classVector
-
listIterator
public ListIterator listIterator(int index)
Iterate while waiting at end until complete.- Specified by:
listIterator
in interfaceList
- Overrides:
listIterator
in classVector
-
remove
public Object 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:
removeAllElements
in classVector
-
removeElement
public boolean removeElement(Object element)
If missing wait until complete.- Overrides:
removeElement
in classVector
-
removeElementAt
public void removeElementAt(int index)
If index is missing wait until reasched or complete.- Overrides:
removeElementAt
in classVector
-
retainAll
public boolean retainAll(Collection collection)
First wait until complete.
-
set
public Object set(int index, Object element)
If index is missing wait until reached or complete.
-
setElementAt
public void setElementAt(Object element, int index)
If index is missing wait until reached or complete.- Overrides:
setElementAt
in classVector
-
size
public int size()
First wait until complete.
-
subList
public List subList(int fromIndex, int toIndex)
If index is missing wait until reached or complete.
-
toArray
public Object[] toArray()
First wait until complete.
-
trimToSize
public void trimToSize()
First wait until complete.- Overrides:
trimToSize
in classVector
-
-