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.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 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 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 aCachedSupplier
.boolean
isTaskScheduled()
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)
-
-
-
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.PrefetchStrategy
Invoked when the prefetch strategy is registered with aCachedSupplier
.- Specified by:
initializeCachedSupplier
in interfaceCachedSupplier.PrefetchStrategy
-
prefetch
public void prefetch(Runnable valueUpdater)
Description copied from interface:CachedSupplier.PrefetchStrategy
Execute the provided value updater to update the cache. The specific implementation defines how this is invoked.- Specified by:
prefetch
in interfaceCachedSupplier.PrefetchStrategy
-
fetch
public <T> RefreshResult<T> fetch(Supplier<RefreshResult<T>> supplier)
Description copied from interface:CachedSupplier.PrefetchStrategy
Invoke 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:
fetch
in interfaceCachedSupplier.PrefetchStrategy
-
close
public void close()
Description copied from interface:CachedSupplier.PrefetchStrategy
Free any resources associated with the strategy. This is invoked when theCachedSupplier.close()
method is invoked.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCachedSupplier.PrefetchStrategy
- Specified by:
close
in interfaceSdkAutoCloseable
-
updateTask
public void updateTask(ScheduledFuture<?> newTask)
-
tryRunBackgroundTask
public void tryRunBackgroundTask(Runnable runnable)
-
runWithInstanceThreadName
public void runWithInstanceThreadName(Runnable runnable)
-
-