Class 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 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 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,
                        E element)
        Add and notify any waiters that there are new elements.
        Specified by:
        add in interface List<E>
        Overrides:
        add in class Vector<E>
      • add

        public boolean add​(E element)
        Add and notify any waiters that there are new elements.
        Specified by:
        add in interface Collection<E>
        Specified by:
        add in interface List<E>
        Overrides:
        add in class Vector<E>
      • addAll

        public boolean addAll​(int index,
                              Collection<? extends E> collection)
        Add and notify any waiters that there are new elements.
        Specified by:
        addAll in interface List<E>
        Overrides:
        addAll in class Vector<E>
      • addAll

        public boolean addAll​(Collection<? extends E> collection)
        Add and notify any waiters that there are new elements.
        Specified by:
        addAll in interface Collection<E>
        Specified by:
        addAll in interface List<E>
        Overrides:
        addAll in class Vector<E>
      • addElement

        public void addElement​(E object)
        Add and notify any waiters that there are new elements.
        Overrides:
        addElement in class Vector<E>
      • clone

        public Object clone()
        First wait until complete.
        Overrides:
        clone in class Vector<E>
      • 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.
      • copyInto

        public void copyInto​(Object[] array)
        First wait until complete.
        Overrides:
        copyInto in class Vector<E>
      • elementAt

        public E elementAt​(int index)
        If the index is beyond the size wait until complete.
        Overrides:
        elementAt in class Vector<E>
      • getSize

        protected int getSize()
      • firstElement

        public E firstElement()
        Wait until has an element or is complete.
        Overrides:
        firstElement in class Vector<E>
      • get

        public E get​(int index)
        Wait until has the element or is complete.
        Specified by:
        get in interface List<E>
        Overrides:
        get in class Vector<E>
      • indexOf

        public int indexOf​(Object element)
        If does not contain the object wait until complete.
        Specified by:
        indexOf in interface List<E>
        Overrides:
        indexOf in class Vector<E>
      • indexOf

        public int indexOf​(Object element,
                           int index)
        If does not contain the object wait until complete.
        Overrides:
        indexOf in class Vector<E>
      • insertElementAt

        public void insertElementAt​(E element,
                                    int index)
        Add the element a notify any waiters that there are new elements.
        Overrides:
        insertElementAt in class Vector<E>
      • isEmpty

        public boolean isEmpty()
        If empty wait until an element has been added or is complete.
        Specified by:
        isEmpty in interface Collection<E>
        Specified by:
        isEmpty in interface List<E>
        Overrides:
        isEmpty in class Vector<E>
      • lastElement

        public E lastElement()
        First wait until complete.
        Overrides:
        lastElement in class Vector<E>
      • lastIndexOf

        public int lastIndexOf​(Object element,
                               int index)
        First wait until complete.
        Overrides:
        lastIndexOf in class Vector<E>
      • remove

        public E remove​(int index)
        If index is missing wait until is there.
        Specified by:
        remove in interface List<E>
        Overrides:
        remove in class Vector<E>
      • removeAllElements

        public void removeAllElements()
        First wait until complete.
        Overrides:
        removeAllElements in class Vector<E>
      • removeElement

        public boolean removeElement​(Object element)
        If missing wait until complete.
        Overrides:
        removeElement in class Vector<E>
      • removeElementAt

        public void removeElementAt​(int index)
        If index is missing wait until reasched or complete.
        Overrides:
        removeElementAt in class Vector<E>
      • set

        public E set​(int index,
                     E element)
        If index is missing wait until reached or complete.
        Specified by:
        set in interface List<E>
        Overrides:
        set in class Vector<E>
      • setElementAt

        public void setElementAt​(E element,
                                 int index)
        If index is missing wait until reached or complete.
        Overrides:
        setElementAt in class Vector<E>
      • size

        public int size()
        First wait until complete.
        Specified by:
        size in interface Collection<E>
        Specified by:
        size in interface List<E>
        Overrides:
        size in class Vector<E>
      • subList

        public List<E> subList​(int fromIndex,
                               int toIndex)
        If index is missing wait until reached or complete.
        Specified by:
        subList in interface List<E>
        Overrides:
        subList in class Vector<E>
      • toString

        public String toString()
        First wait until complete.
        Overrides:
        toString in class Vector<E>
      • trimToSize

        public void trimToSize()
        First wait until complete.
        Overrides:
        trimToSize in class Vector<E>