Package org.eclipse.emf.common.util
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
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.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected WeakInterningHashSet.Entry<E> protected WeakInterningHashSet.Entry<E>[]protected intThe hash code of the object being accessed.protected intThis records duringmatch()the matching index.protected Pool.AccessUnit<E> Access units are chained via this link.protected final Pool.AccessUnit.Queue<E> Access units are maintained for recycled use in this queue.protected Object[]protected intThis records the number ofvaluescached for this access. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(E value, WeakInterningHashSet.Entry<E> entry) Add a value to thevaluesincrementing thevaluesLength.protected WeakInterningHashSet.Entry<E> getEntry()Gets the value that should be added to the pool.protected abstract EgetValue()match()Used to return a value from among thevaluesthatmatches(Object)the value being accessed.protected booleanUsed to determine whether the given value from the pool is equal to the value being accessed.final booleanrematches(E value, WeakInterningHashSet.Entry<E> entry) Used to determine whether the given value from the pool is equal to the value being accessed.voidreset(boolean isExclusive) Prepare the access unit for reuse.protected abstract booleansetArbitraryValue(Object value) protected abstract void
-
Field Details
-
queue
Access units are maintained for recycled use in this queue. -
next
Access units are chained via this link. -
hashCode
protected int hashCodeThe hash code of the object being accessed. -
values
-
valuesLength
protected int valuesLengthThis records the number ofvaluescached for this access. -
matchingIndex
protected int matchingIndexThis records duringmatch()the matching index. -
createdEntry
-
entries
-
-
Constructor Details
-
AccessUnit
-
-
Method Details
-
getValue
-
setValue
-
setArbitraryValue
-
getEntry
-
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
Used to determine whether the given value from the pool is equal to the value being accessed. The default implementation usesObject.equals(Object). -
rematches
Used to determine whether the given value from the pool is equal to the value being accessed. It is called whendouble checkingthe match after acquiring thewrite lockso it can safely any values previous cached. -
match
Used to return a value from among thevaluesthatmatches(Object)the value being accessed. Returnsnullif there is no such matching value. -
add
Add a value to thevaluesincrementing thevaluesLength. -
reset
public void reset(boolean isExclusive) Prepare the access unit for reuse. In particular remove the hard references to each element in both thevaluesandentriesand then reset thevaluesLengthto 0
-