Class Pool.AccessUnit<E>

java.lang.Object
org.eclipse.emf.common.util.Pool.AccessUnit<E>
Direct Known Subclasses:
Pool.ObjectAccessUnit, SegmentSequence.SegmentSequencePool.AccessUnitBase, SegmentSequence.StringArrayPool.AccessUnitBase, URI.URIPool.URIPoolAccessUnitBase
Enclosing class:
Pool<E>

protected abstract static class Pool.AccessUnit<E> extends Object
An access unit is used during access to the pool. It contains a buffer for processing the collision values at a particular index in the WeakInterningHashSet.entries. Access units are recycled for reuse in subsequent accesses. Because of shared multi-threaded read access, there may be as many instances as there are threads simultaneously accessing the pool.
  • Field Details

    • queue

      protected final Pool.AccessUnit.Queue<E> queue
      Access units are maintained for recycled use in this queue.
    • next

      protected Pool.AccessUnit<E> next
      Access units are chained via this link.
    • hashCode

      protected int hashCode
      The hash code of the object being accessed.
    • values

      protected Object[] values
    • valuesLength

      protected int valuesLength
      This records the number of values cached for this access.
    • matchingIndex

      protected int matchingIndex
      This records during match() the matching index.
    • createdEntry

      protected WeakInterningHashSet.Entry<E> createdEntry
    • entries

      protected WeakInterningHashSet.Entry<E>[] entries
  • Constructor Details

  • Method Details

    • getValue

      protected abstract E getValue()
    • setValue

      protected abstract void setValue(E value)
    • setArbitraryValue

      protected abstract boolean setArbitraryValue(Object value)
    • getEntry

      protected WeakInterningHashSet.Entry<E> getEntry()
    • getInternalizedValue

      public E getInternalizedValue()
      Gets the value that should be added to the pool. This can be specialized to internalized the value, e.g., to make a copy that uses minimal storage or is read only.
    • matches

      protected boolean matches(E value)
      Used to determine whether the given value from the pool is equal to the value being accessed. The default implementation uses Object.equals(Object).
    • rematches

      public final boolean rematches(E value, WeakInterningHashSet.Entry<E> entry)
      Used to determine whether the given value from the pool is equal to the value being accessed. It is called when double checking the match after acquiring the write lock so it can safely any values previous cached.
    • match

      public E match()
      Used to return a value from among the values that matches(Object) the value being accessed. Returns null if there is no such matching value.
    • add

      public void add(E value, WeakInterningHashSet.Entry<E> entry)
      Add a value to the values incrementing the valuesLength.
    • reset

      public void reset(boolean isExclusive)
      Prepare the access unit for reuse. In particular remove the hard references to each element in both the values and entries and then reset the valuesLength to 0