Package io.deephaven.engine.table.impl
Class MemoizedResult<R>
java.lang.Object
io.deephaven.engine.table.impl.MemoizedResult<R>
- Type Parameters:
R- the type of the result
An implementation class for a memoized result, which holds a weak reference.
If multiple callers invoke getOrCompute simultaneously; only one caller computes the result; the others block on this object's monitor until the computation is complete.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected RGets the saved result, if it is valid.getOrCompute(Supplier<R> operation) If the reference does not already hold a valid cached value, then execute the provided operation to compute the value, cache it, and return it.
-
Constructor Details
-
MemoizedResult
public MemoizedResult()
-
-
Method Details
-
getOrCompute
If the reference does not already hold a valid cached value, then execute the provided operation to compute the value, cache it, and return it. Otherwise, return the cached value.- Parameters:
operation- the Supplier for our desired result- Returns:
- the cached or newly computed value
-
getIfValid
Gets the saved result, if it is valid. To determine liveness, the result is managed with the current scope before being returned. If the result is not valid, then null is returned.- Returns:
- the result, managed with the current scope (or null if not valid)
-