Package com.google.common.cache
Class LocalCache.SoftValueReference<K,V>
- java.lang.Object
-
- java.lang.ref.Reference<T>
-
- java.lang.ref.SoftReference<V>
-
- com.google.common.cache.LocalCache.SoftValueReference<K,V>
-
- All Implemented Interfaces:
LocalCache.ValueReference<K,V>
- Direct Known Subclasses:
LocalCache.WeightedSoftValueReference
- Enclosing class:
- LocalCache<K,V>
static class LocalCache.SoftValueReference<K,V> extends java.lang.ref.SoftReference<V> implements LocalCache.ValueReference<K,V>
References a soft value.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) ReferenceEntry<K,V>
entry
-
Constructor Summary
Constructors Constructor Description SoftValueReference(java.lang.ref.ReferenceQueue<V> queue, V referent, ReferenceEntry<K,V> entry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LocalCache.ValueReference<K,V>
copyFor(java.lang.ref.ReferenceQueue<V> queue, V value, ReferenceEntry<K,V> entry)
Creates a copy of this reference for the given entry.ReferenceEntry<K,V>
getEntry()
Returns the entry associated with this value reference, ornull
if this value reference is independent of any entry.int
getWeight()
Returns the weight of this entry.boolean
isActive()
Returns true if this reference contains an active value, meaning one that is still considered present in the cache.boolean
isLoading()
Returns true if a new value is currently loading, regardless of whether or not there is an existing value.void
notifyNewValue(V newValue)
Notify pending loads that a new value was set.V
waitForValue()
Waits for a value that may still be loading.-
Methods inherited from class java.lang.ref.Reference
clear, clone, enqueue, isEnqueued, reachabilityFence
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.common.cache.LocalCache.ValueReference
get
-
-
-
-
Field Detail
-
entry
final ReferenceEntry<K,V> entry
-
-
Constructor Detail
-
SoftValueReference
SoftValueReference(java.lang.ref.ReferenceQueue<V> queue, V referent, ReferenceEntry<K,V> entry)
-
-
Method Detail
-
getWeight
public int getWeight()
Description copied from interface:LocalCache.ValueReference
Returns the weight of this entry. This is assumed to be static between calls to setValue.- Specified by:
getWeight
in interfaceLocalCache.ValueReference<K,V>
-
getEntry
public ReferenceEntry<K,V> getEntry()
Description copied from interface:LocalCache.ValueReference
Returns the entry associated with this value reference, ornull
if this value reference is independent of any entry.- Specified by:
getEntry
in interfaceLocalCache.ValueReference<K,V>
-
notifyNewValue
public void notifyNewValue(V newValue)
Description copied from interface:LocalCache.ValueReference
Notify pending loads that a new value was set. This is only relevant to loading value references.- Specified by:
notifyNewValue
in interfaceLocalCache.ValueReference<K,V>
-
copyFor
public LocalCache.ValueReference<K,V> copyFor(java.lang.ref.ReferenceQueue<V> queue, V value, ReferenceEntry<K,V> entry)
Description copied from interface:LocalCache.ValueReference
Creates a copy of this reference for the given entry.value
may be null only for a loading reference.- Specified by:
copyFor
in interfaceLocalCache.ValueReference<K,V>
-
isLoading
public boolean isLoading()
Description copied from interface:LocalCache.ValueReference
Returns true if a new value is currently loading, regardless of whether or not there is an existing value. It is assumed that the return value of this method is constant for any given ValueReference instance.- Specified by:
isLoading
in interfaceLocalCache.ValueReference<K,V>
-
isActive
public boolean isActive()
Description copied from interface:LocalCache.ValueReference
Returns true if this reference contains an active value, meaning one that is still considered present in the cache. Active values consist of live values, which are returned by cache lookups, and dead values, which have been evicted but awaiting removal. Non-active values consist strictly of loading values, though during refresh a value may be both active and loading.- Specified by:
isActive
in interfaceLocalCache.ValueReference<K,V>
-
waitForValue
public V waitForValue()
Description copied from interface:LocalCache.ValueReference
Waits for a value that may still be loading. Unlike get(), this method can block (in the case of FutureValueReference).- Specified by:
waitForValue
in interfaceLocalCache.ValueReference<K,V>
-
-