Class NonBlocking
- java.lang.Object
-
- software.amazon.awssdk.utils.cache.NonBlocking
-
- All Implemented Interfaces:
AutoCloseable,CachedSupplier.PrefetchStrategy,SdkAutoCloseable
public class NonBlocking extends Object implements CachedSupplier.PrefetchStrategy
ACachedSupplier.PrefetchStrategythat will run a single thread in the background to update the value. A call to prefetch on this strategy will never return. Multiple calls toprefetch(Runnable)will still only result in one background task performing the update.
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Free any resources associated with the strategy.<T> RefreshResult<T>fetch(Supplier<RefreshResult<T>> supplier)Invoke the provided supplier to retrieve the refresh result.voidinitializeCachedSupplier(CachedSupplier<?> cachedSupplier)Invoked when the prefetch strategy is registered with aCachedSupplier.booleanisTaskScheduled()voidprefetch(Runnable valueUpdater)Execute the provided value updater to update the cache.voidrunWithInstanceThreadName(Runnable runnable)voidtryRunBackgroundTask(Runnable runnable)voidtryRunBackgroundTask(Runnable runnable, Runnable runOnCompletion)voidupdateTask(ScheduledFuture<?> newTask)
-
-
-
Constructor Detail
-
NonBlocking
public 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.
-
-
Method Detail
-
isTaskScheduled
public boolean isTaskScheduled()
-
initializeCachedSupplier
public void initializeCachedSupplier(CachedSupplier<?> cachedSupplier)
Description copied from interface:CachedSupplier.PrefetchStrategyInvoked when the prefetch strategy is registered with aCachedSupplier.- Specified by:
initializeCachedSupplierin interfaceCachedSupplier.PrefetchStrategy
-
prefetch
public void prefetch(Runnable valueUpdater)
Description copied from interface:CachedSupplier.PrefetchStrategyExecute the provided value updater to update the cache. The specific implementation defines how this is invoked.- Specified by:
prefetchin interfaceCachedSupplier.PrefetchStrategy
-
fetch
public <T> RefreshResult<T> fetch(Supplier<RefreshResult<T>> supplier)
Description copied from interface:CachedSupplier.PrefetchStrategyInvoke the provided supplier to retrieve the refresh result. This is useful for prefetch strategies to override when they care about the refresh result.- Specified by:
fetchin interfaceCachedSupplier.PrefetchStrategy
-
close
public void close()
Description copied from interface:CachedSupplier.PrefetchStrategyFree any resources associated with the strategy. This is invoked when theCachedSupplier.close()method is invoked.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCachedSupplier.PrefetchStrategy- Specified by:
closein interfaceSdkAutoCloseable
-
updateTask
public void updateTask(ScheduledFuture<?> newTask)
-
tryRunBackgroundTask
public void tryRunBackgroundTask(Runnable runnable)
-
runWithInstanceThreadName
public void runWithInstanceThreadName(Runnable runnable)
-
-