public class TinyAsync extends Object implements AsyncFramework
TinyAsync async = TinyAsync.builder().caller(new Slf4jCaller()).build();
final ResolvableFuture<Integer> future = async.future()
someAsyncOperation(future);
future.on(new FutureDone<Integer>() {
void resolved(Integer result) {
// hurray
}
void failed(Throwable cause) {
// nay :(
}
});
| Modifier and Type | Field and Description |
|---|---|
protected static Collector<? extends Object,? extends Collection<? extends Object>> |
collectCollector |
protected LazyTransform<? extends AsyncFuture<?>,?> |
lazyCallTransform |
| Modifier | Constructor and Description |
|---|---|
protected |
TinyAsync(ExecutorService defaultExecutor,
AsyncCaller caller,
AsyncCaller threadedCaller,
ScheduledExecutorService scheduler,
ClockSource clockSource) |
| Modifier and Type | Method and Description |
|---|---|
protected <T> void |
bindSignals(AsyncFuture<T> target,
Collection<? extends AsyncFuture<?>> futures)
Bind the given collection of futures to the target future, which if cancelled, or failed will
do the corresponding to their collection of futures.
|
static TinyAsyncBuilder |
builder()
Build a new TinyAsync instance.
|
<C> AsyncFuture<C> |
call(Callable<? extends C> callable) |
<C> AsyncFuture<C> |
call(Callable<? extends C> callable,
ExecutorService executor) |
<C> AsyncFuture<C> |
call(Callable<? extends C> callable,
ExecutorService executor,
ResolvableFuture<C> future) |
AsyncCaller |
caller() |
<T> AsyncFuture<T> |
cancelled() |
<T> AsyncFuture<T> |
cancelled(AsyncFuture<T> future,
LazyTransform<Void,? extends T> transform) |
<T> AsyncFuture<T> |
cancelled(AsyncFuture<T> future,
Transform<Void,? extends T> transform) |
<C,T> AsyncFuture<T> |
collect(Collection<? extends AsyncFuture<? extends C>> futures,
Collector<? super C,? extends T> collector) |
<C,T> AsyncFuture<T> |
collect(Collection<? extends AsyncFuture<? extends C>> futures,
StreamCollector<? super C,? extends T> collector) |
<T> AsyncFuture<Collection<T>> |
collect(Collection<? extends AsyncFuture<? extends T>> futures) |
<C> AsyncFuture<Void> |
collectAndDiscard(Collection<? extends AsyncFuture<C>> futures) |
protected <T> Collector<T,Collection<T>> |
collection() |
ExecutorService |
defaultExecutor()
Fetch the configured primary executor (if any).
|
protected <C,T> AsyncFuture<T> |
doCollect(Collection<? extends AsyncFuture<? extends C>> futures,
Collector<? super C,? extends T> collector) |
protected <T,C> AsyncFuture<T> |
doCollect(Collection<? extends AsyncFuture<? extends C>> futures,
StreamCollector<? super C,? extends T> collector) |
protected <C> AsyncFuture<Void> |
doCollectAndDiscard(Collection<? extends AsyncFuture<C>> futures) |
protected <C,T> AsyncFuture<T> |
doCollectEmpty(Collector<C,? extends T> collector)
Shortcut for when the list of futures is empty.
|
protected <C,T> AsyncFuture<T> |
doCollectEmpty(StreamCollector<? super C,? extends T> collector)
Shortcut for when the list of futures is empty with
StreamCollector. |
protected <T,C> AsyncFuture<T> |
doEventuallyCollect(Collection<? extends Callable<? extends AsyncFuture<? extends C>>> callables,
StreamCollector<? super C,? extends T> collector,
int parallelism) |
protected <T,C> AsyncFuture<T> |
doEventuallyCollectEmpty(StreamCollector<? super C,? extends T> collector) |
protected <C,T> AsyncFuture<T> |
doEventuallyCollectImmediate(Collection<? extends Callable<? extends AsyncFuture<? extends C>>> callables,
StreamCollector<? super C,? extends T> collector) |
<T> AsyncFuture<T> |
error(AsyncFuture<T> future,
LazyTransform<Throwable,? extends T> transform) |
<T> AsyncFuture<T> |
error(AsyncFuture<T> future,
Transform<Throwable,? extends T> transform) |
<C,T> AsyncFuture<T> |
eventuallyCollect(Collection<? extends Callable<? extends AsyncFuture<? extends C>>> callables,
StreamCollector<? super C,? extends T> collector,
int parallelism) |
<T> AsyncFuture<T> |
failed(Throwable e) |
<T> ResolvableFuture<T> |
future() |
<T> AsyncFuture<T> |
lazyCall(Callable<? extends AsyncFuture<T>> callable) |
<T> AsyncFuture<T> |
lazyCall(Callable<? extends AsyncFuture<T>> callable,
ExecutorService executor) |
protected <T> LazyTransform<AsyncFuture<T>,T> |
lazyCallTransform() |
<C> Managed<C> |
managed(ManagedSetup<C> setup) |
<C> ReloadableManaged<C> |
reloadableManaged(ManagedSetup<C> setup) |
AsyncFuture<Void> |
resolved() |
<T> AsyncFuture<T> |
resolved(T value) |
<T> AsyncFuture<RetryResult<T>> |
retryUntilResolved(Callable<? extends AsyncFuture<? extends T>> action,
RetryPolicy policy) |
<T> AsyncFuture<RetryResult<T>> |
retryUntilResolved(Callable<? extends AsyncFuture<? extends T>> action,
RetryPolicy policy,
ClockSource clockSource) |
AsyncCaller |
threadedCaller() |
<C,T> AsyncFuture<T> |
transform(AsyncFuture<C> future,
LazyTransform<? super C,? extends T> transform) |
<C,T> AsyncFuture<T> |
transform(AsyncFuture<C> future,
Transform<? super C,? extends T> transform) |
protected final LazyTransform<? extends AsyncFuture<?>,?> lazyCallTransform
protected static final Collector<? extends Object,? extends Collection<? extends Object>> collectCollector
protected TinyAsync(ExecutorService defaultExecutor, AsyncCaller caller, AsyncCaller threadedCaller, ScheduledExecutorService scheduler, ClockSource clockSource)
public ExecutorService defaultExecutor()
IllegalStateException - if no caller executor is available.public AsyncCaller threadedCaller()
threadedCaller in interface AsyncFrameworkpublic AsyncCaller caller()
caller in interface AsyncFrameworkpublic <C,T> AsyncFuture<T> transform(AsyncFuture<C> future, Transform<? super C,? extends T> transform)
transform in interface AsyncFrameworkpublic <C,T> AsyncFuture<T> transform(AsyncFuture<C> future, LazyTransform<? super C,? extends T> transform)
transform in interface AsyncFrameworkpublic <T> AsyncFuture<T> error(AsyncFuture<T> future, Transform<Throwable,? extends T> transform)
error in interface AsyncFrameworkpublic <T> AsyncFuture<T> error(AsyncFuture<T> future, LazyTransform<Throwable,? extends T> transform)
error in interface AsyncFrameworkpublic <T> AsyncFuture<T> cancelled(AsyncFuture<T> future, Transform<Void,? extends T> transform)
cancelled in interface AsyncFrameworkpublic <T> AsyncFuture<T> cancelled(AsyncFuture<T> future, LazyTransform<Void,? extends T> transform)
cancelled in interface AsyncFrameworkpublic <C> AsyncFuture<C> call(Callable<? extends C> callable)
call in interface AsyncFrameworkpublic <T> AsyncFuture<T> lazyCall(Callable<? extends AsyncFuture<T>> callable)
lazyCall in interface AsyncFrameworkpublic <C> AsyncFuture<C> call(Callable<? extends C> callable, ExecutorService executor)
call in interface AsyncFrameworkpublic <T> AsyncFuture<T> lazyCall(Callable<? extends AsyncFuture<T>> callable, ExecutorService executor)
lazyCall in interface AsyncFrameworkprotected <T> LazyTransform<AsyncFuture<T>,T> lazyCallTransform()
public <C> AsyncFuture<C> call(Callable<? extends C> callable, ExecutorService executor, ResolvableFuture<C> future)
call in interface AsyncFrameworkpublic <T> ResolvableFuture<T> future()
future in interface AsyncFrameworkpublic AsyncFuture<Void> resolved()
resolved in interface AsyncFrameworkpublic <T> AsyncFuture<T> resolved(T value)
resolved in interface AsyncFrameworkpublic <T> AsyncFuture<T> failed(Throwable e)
failed in interface AsyncFrameworkpublic <T> AsyncFuture<T> cancelled()
cancelled in interface AsyncFrameworkpublic <T> AsyncFuture<Collection<T>> collect(Collection<? extends AsyncFuture<? extends T>> futures)
collect in interface AsyncFrameworkpublic <C,T> AsyncFuture<T> collect(Collection<? extends AsyncFuture<? extends C>> futures, Collector<? super C,? extends T> collector)
collect in interface AsyncFrameworkprotected <C,T> AsyncFuture<T> doCollect(Collection<? extends AsyncFuture<? extends C>> futures, Collector<? super C,? extends T> collector)
protected <C,T> AsyncFuture<T> doCollectEmpty(Collector<C,? extends T> collector)
public <C,T> AsyncFuture<T> collect(Collection<? extends AsyncFuture<? extends C>> futures, StreamCollector<? super C,? extends T> collector)
collect in interface AsyncFrameworkprotected <T,C> AsyncFuture<T> doCollect(Collection<? extends AsyncFuture<? extends C>> futures, StreamCollector<? super C,? extends T> collector)
public <C,T> AsyncFuture<T> eventuallyCollect(Collection<? extends Callable<? extends AsyncFuture<? extends C>>> callables, StreamCollector<? super C,? extends T> collector, int parallelism)
eventuallyCollect in interface AsyncFrameworkprotected <T> Collector<T,Collection<T>> collection()
protected <T,C> AsyncFuture<T> doEventuallyCollectEmpty(StreamCollector<? super C,? extends T> collector)
protected <C,T> AsyncFuture<T> doEventuallyCollectImmediate(Collection<? extends Callable<? extends AsyncFuture<? extends C>>> callables, StreamCollector<? super C,? extends T> collector)
protected <T,C> AsyncFuture<T> doEventuallyCollect(Collection<? extends Callable<? extends AsyncFuture<? extends C>>> callables, StreamCollector<? super C,? extends T> collector, int parallelism)
protected <C,T> AsyncFuture<T> doCollectEmpty(StreamCollector<? super C,? extends T> collector)
StreamCollector.public <C> AsyncFuture<Void> collectAndDiscard(Collection<? extends AsyncFuture<C>> futures)
collectAndDiscard in interface AsyncFrameworkprotected <C> AsyncFuture<Void> doCollectAndDiscard(Collection<? extends AsyncFuture<C>> futures)
public <C> Managed<C> managed(ManagedSetup<C> setup)
managed in interface AsyncFrameworkpublic <C> ReloadableManaged<C> reloadableManaged(ManagedSetup<C> setup)
reloadableManaged in interface AsyncFrameworkpublic static TinyAsyncBuilder builder()
protected <T> void bindSignals(AsyncFuture<T> target, Collection<? extends AsyncFuture<?>> futures)
target - The future to cancel, and fail on.futures - The futures to cancel, when target is cancelled.public <T> AsyncFuture<RetryResult<T>> retryUntilResolved(Callable<? extends AsyncFuture<? extends T>> action, RetryPolicy policy)
retryUntilResolved in interface AsyncFrameworkpublic <T> AsyncFuture<RetryResult<T>> retryUntilResolved(Callable<? extends AsyncFuture<? extends T>> action, RetryPolicy policy, ClockSource clockSource)
retryUntilResolved in interface AsyncFrameworkCopyright © 2017. All rights reserved.