Class AsyncSupplier<T>
- java.lang.Object
-
- com.palantir.atlasdb.keyvalue.cassandra.pool.AsyncSupplier<T>
-
- All Implemented Interfaces:
java.util.function.Supplier<Optional<T>>
@ThreadSafe public final class AsyncSupplier<T> extends Object implements java.util.function.Supplier<Optional<T>>
Supplier that will evaluate a delegate supplier asynchronously, returningOptional.empty()
until the underlying result is complete, at which point it will be returned. This computation is only initiated after the first call to get, but will be memoized infinitely after that. If the delegate throws, it will not be retried andOptional.empty()
will be returned for the lifecycle of this supplier. Note that this class is responsible for creating and shutting down any executors. This class is thread safe by synchronising onget()
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> AsyncSupplier<T>
create(java.util.function.Supplier<Optional<T>> delegate)
Optional<T>
get()
-
-
-
Method Detail
-
create
public static <T> AsyncSupplier<T> create(java.util.function.Supplier<Optional<T>> delegate)
-
-