Class AsyncSupplier<T>
- java.lang.Object
-
- com.palantir.atlasdb.keyvalue.cassandra.pool.AsyncSupplier<T>
-
- All Implemented Interfaces:
java.util.function.Supplier<java.util.Optional<T>>
@ThreadSafe public final class AsyncSupplier<T> extends java.lang.Object implements java.util.function.Supplier<java.util.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<java.util.Optional<T>> delegate)
java.util.Optional<T>
get()
-
-
-
Method Detail
-
get
public java.util.Optional<T> get()
- Specified by:
get
in interfacejava.util.function.Supplier<T>
-
create
public static <T> AsyncSupplier<T> create(java.util.function.Supplier<java.util.Optional<T>> delegate)
-
-