T
- public class ComputedValue<T> extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
ComputedValue.Computation<T>
Computation
|
Constructor and Description |
---|
ComputedValue(Object aLock,
ComputedValue.Computation aComputation)
Constructs the compute guard
|
Modifier and Type | Method and Description |
---|---|
void |
compute()
Triggers computation of the value (if no other thread is currently
computing the value).
|
T |
get()
Gets the current value of the object, recomputing it if the object is out
of date.
|
T |
getCached()
Gets the currently cached value.
|
void |
set(T aValue)
Sets the value explicitly.
|
public ComputedValue(Object aLock, ComputedValue.Computation aComputation)
aLock
- Lock to use during computation and to guard the value.aComputation
- Computation to use.public void compute()
public T get()
public T getCached()
public void set(T aValue)
aValue
- value to set.Copyright © 2024. All rights reserved.