|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public static interface CustomConcurrentHashMap.ComputingStrategy<K,V,E>
Extends CustomConcurrentHashMap.Strategy to add support for computing values on-demand.
Implementations should typically intialize the entry's value to a
placeholder value in CustomConcurrentHashMap.Strategy.newEntry(Object, int, Object) so that
waitForValue(Object) can tell the difference between a
pre-intialized value and an in-progress computation. CustomConcurrentHashMap.Strategy.copyEntry(Object, Object, Object) must detect and handle the case where
an entry is copied in the middle of a computation. Implementations can
throw UnsupportedOperationException in CustomConcurrentHashMap.Strategy.setValue(Object,
Object) if they wish to prevent users from setting values directly.
CustomConcurrentHashMap.Builder.buildComputingMap(CustomConcurrentHashMap.ComputingStrategy, Function)| Method Summary | |
|---|---|
V |
compute(K key,
E entry,
Function<? super K,? extends V> computer)
Computes a value for the given key and stores it in the given entry. |
V |
waitForValue(E entry)
Gets a value from an entry waiting for the value to be set by compute(K, E, com.google.common.base.Function super K, ? extends V>) if necessary. |
| Methods inherited from interface com.google.common.collect.CustomConcurrentHashMap.Strategy |
|---|
copyEntry, equalKeys, equalValues, getHash, getKey, getNext, getValue, hashKey, newEntry, setInternals, setValue |
| Method Detail |
|---|
V compute(K key,
E entry,
Function<? super K,? extends V> computer)
Map.get(java.lang.Object). If this method throws an
exception, CustomConcurrentHashMap will remove the entry and retry
the computation on subsequent requests.
entry - that was createdcomputer - passed to CustomConcurrentHashMap.Builder.buildMap(com.google.common.collect.CustomConcurrentHashMap.Strategy)
ComputationException - if the computation threw an exception
java.lang.NullPointerException - if the computer returned null
V waitForValue(E entry)
throws java.lang.InterruptedException
compute(K, E, com.google.common.base.Function super K, ? extends V>) if necessary. Returns null if a value isn't available at
which point CustomConcurrentHashMap tries to compute a new value.
entry - to return value from
java.lang.InterruptedException - if the thread was interrupted while
waiting
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||