if (previousValue == null) { V newValue = loader.load(key); return set(newValue) ? futureValue : Futures.immediateFuture(newValue);
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> function) { stopwatch.start(); V previousValue; try { previousValue = oldValue.waitForValue(); } catch (ExecutionException e) { previousValue = null; } V newValue; try { newValue = function.apply(key, previousValue); } catch (Throwable th) { this.setException(th); throw th; } this.set(newValue); return newValue; }
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> function) { stopwatch.start(); V previousValue; try { previousValue = oldValue.waitForValue(); } catch (ExecutionException e) { previousValue = null; } V newValue = function.apply(key, previousValue); this.set(newValue); return newValue; }
@Override public void notifyNewValue(@Nullable V newValue) { if (newValue != null) { // The pending load was clobbered by a manual write. // Unblock all pending gets, and have them return the new value. set(newValue); } else { // The pending load was removed. Delay notifications until loading completes. oldValue = unset(); } // TODO(fry): could also cancel loading if we had a handle on its future }
@Override public void run() { try { V newValue = getAndRecordStats(key, hash, loadingValueReference, loadingFuture); // update loadingFuture for the sake of other pending requests loadingValueReference.set(newValue); } catch (Throwable t) { logger.log(Level.WARNING, "Exception thrown during refresh", t); loadingValueReference.setException(t); } } }, sameThreadExecutor);
@Override public V apply(V newValue) { LoadingValueReference.this.set(newValue); return newValue; } });
@Override public void notifyNewValue(@Nullable V newValue) { if (newValue != null) { // The pending load was clobbered by a manual write. // Unblock all pending gets, and have them return the new value. set(newValue); } else { // The pending load was removed. Delay notifications until loading completes. oldValue = unset(); } // TODO(fry): could also cancel loading if we had a handle on its future }
@Override public void notifyNewValue(@Nullable V newValue) { if (newValue != null) { // The pending load was clobbered by a manual write. // Unblock all pending gets, and have them return the new value. set(newValue); } else { // The pending load was removed. Delay notifications until loading completes. oldValue = unset(); } // TODO(fry): could also cancel loading if we had a handle on its future }
@Override public void notifyNewValue(@Nullable V newValue) { if (newValue != null) { // The pending load was clobbered by a manual write. // Unblock all pending gets, and have them return the new value. set(newValue); } else { // The pending load was removed. Delay notifications until loading completes. oldValue = unset(); } // TODO(fry): could also cancel loading if we had a handle on its future }
@Override public void notifyNewValue(@Nullable V newValue) { if (newValue != null) { // The pending load was clobbered by a manual write. // Unblock all pending gets, and have them return the new value. set(newValue); } else { // The pending load was removed. Delay notifications until loading completes. oldValue = unset(); } // TODO(fry): could also cancel loading if we had a handle on its future }
@Override public void notifyNewValue(@Nullable V newValue) { if (newValue != null) { // The pending load was clobbered by a manual write. // Unblock all pending gets, and have them return the new value. set(newValue); } else { // The pending load was removed. Delay notifications until loading completes. oldValue = unset(); } // TODO(fry): could also cancel loading if we had a handle on its future }
@Override public V apply(V newValue) { LoadingValueReference.this.set(newValue); return newValue; } });
@Override public V apply(V newValue) { LoadingValueReference.this.set(newValue); return newValue; } });
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> function) { stopwatch.start(); V previousValue; try { previousValue = oldValue.waitForValue(); } catch (ExecutionException e) { previousValue = null; } V newValue = function.apply(key, previousValue); this.set(newValue); return newValue; }
if (newValue != null) { if (valueReference != null && newValue == valueReference.get()) { loadingValueReference.set(newValue); setValue(e, key, newValue, now); return newValue;
if (previousValue == null) { V newValue = loader.load(key); return set(newValue) ? futureValue : Futures.immediateFuture(newValue);
if (newValue != null) { if (valueReference != null && newValue == valueReference.get()) { loadingValueReference.set(newValue); e.setValueReference(valueReference); recordWrite(e, 0, now); // no change in weight
@Override public void notifyNewValue(@NullableDecl V newValue) { if (newValue != null) { // The pending load was clobbered by a manual write. // Unblock all pending gets, and have them return the new value. set(newValue); } else { // The pending load was removed. Delay notifications until loading completes. oldValue = unset(); } // TODO(fry): could also cancel loading if we had a handle on its future }
@Override public V apply(V newValue) { LoadingValueReference.this.set(newValue); return newValue; } },
@Override public void notifyNewValue(@Nullable V newValue) { if (newValue != null) { // The pending load was clobbered by a manual write. // Unblock all pending gets, and have them return the new value. set(newValue); } else { // The pending load was removed. Delay notifications until loading completes. oldValue = unset(); } // TODO(fry): could also cancel loading if we had a handle on its future }