|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.wamblee.cache.ComputedValue<T>
T - public class ComputedValue<T>
Utility class to deal with recomputation of a certain value. The goal is to have only one thread at a time compute the value while other threads that simulateneously detect recomputation continue with the old value.
| Nested Class Summary | |
|---|---|
static interface |
ComputedValue.Computation<T>
Computation |
| Constructor Summary | |
|---|---|
ComputedValue(Object aLock,
ComputedValue.Computation aComputation)
Constructs the compute guard |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ComputedValue(Object aLock,
ComputedValue.Computation aComputation)
aLock - Lock to use during computation and to guard the value.aComputation - Computation to use.| Method Detail |
|---|
public void compute()
public T get()
public T getCached()
public void set(T aValue)
aValue - value to set.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||