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

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

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

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

        public void clear()
        First wait until complete.
        Specified by:
        clear in interface Collection
        Specified by:
        clear in interface List
        Overrides:
        clear in class Vector
      • clone

        public Object clone()
        First wait until complete.
        Overrides:
        clone in class Vector
      • 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.
        Specified by:
        contains in interface Collection
        Specified by:
        contains in interface List
        Overrides:
        contains in class Vector
      • copyInto

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

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

        protected int getSize()
      • firstElement

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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