Package com.google.common.collect
Class MapMakerInternalMap.WeakKeyWeakValueSegment<K,V>
java.lang.Object
java.util.concurrent.locks.ReentrantLock
com.google.common.collect.MapMakerInternalMap.Segment<K,V,MapMakerInternalMap.WeakKeyWeakValueEntry<K,V>,MapMakerInternalMap.WeakKeyWeakValueSegment<K,V>>
com.google.common.collect.MapMakerInternalMap.WeakKeyWeakValueSegment<K,V>
- All Implemented Interfaces:
Serializable
,Lock
- Enclosing class:
MapMakerInternalMap<K,
V, E extends MapMakerInternalMap.InternalEntry<K, V, E>, S extends MapMakerInternalMap.Segment<K, V, E, S>>
static final class MapMakerInternalMap.WeakKeyWeakValueSegment<K,V>
extends MapMakerInternalMap.Segment<K,V,MapMakerInternalMap.WeakKeyWeakValueEntry<K,V>,MapMakerInternalMap.WeakKeyWeakValueSegment<K,V>>
Concrete implementation of
MapMakerInternalMap.Segment
for weak keys and weak values.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionWeakKeyWeakValueSegment
(MapMakerInternalMap<K, V, MapMakerInternalMap.WeakKeyWeakValueEntry<K, V>, MapMakerInternalMap.WeakKeyWeakValueSegment<K, V>> map, int initialCapacity) -
Method Summary
Modifier and TypeMethodDescriptioncastForTesting
(MapMakerInternalMap.InternalEntry<K, V, ?> entry) Unsafe cast of the given entry toE
, the type of the specificMapMakerInternalMap.InternalEntry
implementation type.(package private) ReferenceQueue
<K> Unsafely extracts the key reference queue used by this segment.(package private) ReferenceQueue
<V> Unsafely extracts the value reference queue used by this segment.Unsafely extracts the weak value reference inside of the givenentry
.(package private) void
Clears the reference queues used by this segment, if any.(package private) void
Drains the reference queues used by this segment, if any.newWeakValueReferenceForTesting
(MapMakerInternalMap.InternalEntry<K, V, ?> e, V value) Unsafely creates of a freshMapMakerInternalMap.WeakValueReference
, referencing the givenvalue
, for the givenentry
(package private) MapMakerInternalMap.WeakKeyWeakValueSegment
<K, V> self()
void
setWeakValueReferenceForTesting
(MapMakerInternalMap.InternalEntry<K, V, ?> e, MapMakerInternalMap.WeakValueReference<K, V, ? extends MapMakerInternalMap.InternalEntry<K, V, ?>> valueReference) Unsafely sets the weak value reference inside the givenentry
to be the givenvalueReference
Methods inherited from class com.google.common.collect.MapMakerInternalMap.Segment
clear, clearReferenceQueue, clearValueForTesting, containsKey, containsValue, copyEntry, copyForTesting, drainKeyReferenceQueue, drainValueReferenceQueue, expand, get, getEntry, getFirst, getLiveEntry, getLiveValue, getLiveValueForTesting, initTable, isCollected, newEntryArray, newEntryForTesting, postReadCleanup, preWriteCleanup, put, reclaimKey, reclaimValue, remove, remove, removeEntryForTesting, removeFromChain, removeFromChainForTesting, removeTableEntryForTesting, replace, replace, runCleanup, runLockedCleanup, setTableEntryForTesting, setValue, setValueForTesting, tryDrainReferenceQueues
Methods inherited from class java.util.concurrent.locks.ReentrantLock
getHoldCount, getOwner, getQueuedThreads, getQueueLength, getWaitingThreads, getWaitQueueLength, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isHeldByCurrentThread, isLocked, lock, lockInterruptibly, newCondition, toString, tryLock, tryLock, unlock
-
Field Details
-
queueForKeys
-
queueForValues
-
-
Constructor Details
-
WeakKeyWeakValueSegment
WeakKeyWeakValueSegment(MapMakerInternalMap<K, V, MapMakerInternalMap.WeakKeyWeakValueEntry<K, V>, MapMakerInternalMap.WeakKeyWeakValueSegment<K, V>> map, int initialCapacity)
-
-
Method Details
-
self
Description copied from class:MapMakerInternalMap.Segment
Returnsthis
up-casted to the specificMapMakerInternalMap.Segment
implementation typeS
.This method exists so that the
MapMakerInternalMap.Segment
code can be generic in terms ofS
, the type of the concrete implementation.- Specified by:
self
in classMapMakerInternalMap.Segment<K,
V, MapMakerInternalMap.WeakKeyWeakValueEntry<K, V>, MapMakerInternalMap.WeakKeyWeakValueSegment<K, V>>
-
getKeyReferenceQueueForTesting
ReferenceQueue<K> getKeyReferenceQueueForTesting()Description copied from class:MapMakerInternalMap.Segment
Unsafely extracts the key reference queue used by this segment. -
getValueReferenceQueueForTesting
ReferenceQueue<V> getValueReferenceQueueForTesting()Description copied from class:MapMakerInternalMap.Segment
Unsafely extracts the value reference queue used by this segment. -
castForTesting
@CheckForNull public MapMakerInternalMap.WeakKeyWeakValueEntry<K,V> castForTesting(@CheckForNull MapMakerInternalMap.InternalEntry<K, V, ?> entry) Description copied from class:MapMakerInternalMap.Segment
Unsafe cast of the given entry toE
, the type of the specificMapMakerInternalMap.InternalEntry
implementation type.This method is provided as a convenience for tests. Otherwise they'd need to be knowledgeable about all the implementation details of our type system trickery.
- Specified by:
castForTesting
in classMapMakerInternalMap.Segment<K,
V, MapMakerInternalMap.WeakKeyWeakValueEntry<K, V>, MapMakerInternalMap.WeakKeyWeakValueSegment<K, V>>
-
getWeakValueReferenceForTesting
public MapMakerInternalMap.WeakValueReference<K,V, getWeakValueReferenceForTestingMapMakerInternalMap.WeakKeyWeakValueEntry<K, V>> (MapMakerInternalMap.InternalEntry<K, V, ?> e) Description copied from class:MapMakerInternalMap.Segment
Unsafely extracts the weak value reference inside of the givenentry
. -
newWeakValueReferenceForTesting
public MapMakerInternalMap.WeakValueReference<K,V, newWeakValueReferenceForTestingMapMakerInternalMap.WeakKeyWeakValueEntry<K, V>> (MapMakerInternalMap.InternalEntry<K, V, ?> e, V value) Description copied from class:MapMakerInternalMap.Segment
Unsafely creates of a freshMapMakerInternalMap.WeakValueReference
, referencing the givenvalue
, for the givenentry
-
setWeakValueReferenceForTesting
public void setWeakValueReferenceForTesting(MapMakerInternalMap.InternalEntry<K, V, ?> e, MapMakerInternalMap.WeakValueReference<K, V, ? extends MapMakerInternalMap.InternalEntry<K, V, ?>> valueReference) Description copied from class:MapMakerInternalMap.Segment
Unsafely sets the weak value reference inside the givenentry
to be the givenvalueReference
-
maybeDrainReferenceQueues
void maybeDrainReferenceQueues()Description copied from class:MapMakerInternalMap.Segment
Drains the reference queues used by this segment, if any. -
maybeClearReferenceQueues
void maybeClearReferenceQueues()Description copied from class:MapMakerInternalMap.Segment
Clears the reference queues used by this segment, if any.
-