Class Functions.WeakMemoizer<A,B>
java.lang.Object
io.atlassian.fugue.Functions.WeakMemoizer<A,B>
- Type Parameters:
A- comparable descriptor, the usual rules for anyHashMapkey apply.B- the value
- All Implemented Interfaces:
Function<A,B>
- Enclosing class:
Functions
Class supports the implementation of
Functions.weakMemoize(Function) and is not intended for general
use.
Functions.WeakMemoizer caches the result of another function. The result is
weakly referenced internally. This is useful if the
result is expensive to compute or the identity of the result is
particularly important.
If the results from this function are further cached then they will tend to stay in this cache for longer.
- Since:
- 1.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classA weak reference that maintains a reference to the key so that it can be removed from the map when the value is garbage collected. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap<A, Functions.WeakMemoizer.MappedReference<A, B>> private final ReferenceQueue<B> -
Constructor Summary
ConstructorsConstructorDescriptionWeakMemoizer(Function<A, B> delegate) Construct a newFunctions.WeakMemoizerinstance. -
Method Summary
Modifier and TypeMethodDescriptionGet a result for the supplied Descriptor.private void(package private) static <A,B> Functions.WeakMemoizer <A, B> weakMemoizer(Function<A, B> delegate)
-
Field Details
-
map
-
queue
-
delegate
-
-
Constructor Details
-
WeakMemoizer
Construct a newFunctions.WeakMemoizerinstance.- Parameters:
delegate- for creating the initial values.
-
-
Method Details
-
weakMemoizer
-
apply
-
expungeStaleEntries
private void expungeStaleEntries()
-