public class NonBlocking extends Object implements CachedSupplier.PrefetchStrategy
CachedSupplier.PrefetchStrategy that will run a single thread in the background to update the value. A call to
prefetch on this strategy will never return.
Multiple calls to prefetch(Runnable) will still only result in one background task performing the update.| Constructor and Description |
|---|
NonBlocking(String asyncThreadName)
Create a non-blocking prefetch strategy that uses the provided value for the name of the background thread that will be
performing the update.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Free any resources associated with the strategy.
|
<T> RefreshResult<T> |
fetch(Supplier<RefreshResult<T>> supplier)
Invoke the provided supplier to retrieve the refresh result.
|
void |
initializeCachedSupplier(CachedSupplier<?> cachedSupplier)
Invoked when the prefetch strategy is registered with a
CachedSupplier. |
void |
prefetch(Runnable valueUpdater)
Execute the provided value updater to update the cache.
|
void |
runWithInstanceThreadName(Runnable runnable) |
void |
tryRunBackgroundTask(Runnable runnable) |
void |
tryRunBackgroundTask(Runnable runnable,
Runnable runOnCompletion) |
void |
updateTask(ScheduledFuture<?> newTask) |
public NonBlocking(String asyncThreadName)
public void initializeCachedSupplier(CachedSupplier<?> cachedSupplier)
CachedSupplier.PrefetchStrategyCachedSupplier.initializeCachedSupplier in interface CachedSupplier.PrefetchStrategypublic void prefetch(Runnable valueUpdater)
CachedSupplier.PrefetchStrategyprefetch in interface CachedSupplier.PrefetchStrategypublic <T> RefreshResult<T> fetch(Supplier<RefreshResult<T>> supplier)
CachedSupplier.PrefetchStrategyfetch in interface CachedSupplier.PrefetchStrategypublic void close()
CachedSupplier.PrefetchStrategyCachedSupplier.close() method is
invoked.close in interface AutoCloseableclose in interface CachedSupplier.PrefetchStrategyclose in interface SdkAutoCloseablepublic void updateTask(ScheduledFuture<?> newTask)
public void tryRunBackgroundTask(Runnable runnable)
public void runWithInstanceThreadName(Runnable runnable)
Copyright © 2023. All rights reserved.