Skip to content

FutureW

johnmcclean-aol edited this page Nov 21, 2016 · 7 revisions

FutureW(rapper)

Why?

CompletableFuture has a non-standard API, FutureW provides a more standard API with all of cyclops-react advanced features.

Stream

Stream

Optional

Optional

### CompletableFuture

CompletableFuture

FutureW

FutureW)

Features

Quorum support

Return a List of results of a quorum of FutureWs

FutureW<Integer> one = FutureW.ofSupplier(()->1);
FutureW<Integer> two = FutureW.ofSupplier(()->2);
FutureW<Integer> three = FutureW.future(); //started but not complete
FutureW<ListX<Integer>> strings = FutureW.quorum(status -> status.getCompleted() > 1,
                                                   ,one,two,three);
               

assertThat(strings.get().size(), is(greaterThan(1)));

First success

FutureW<Integer> ft = FutureW.future();
FutureW<Integer> ft = FutureW.ofError(new NoSuchElementException());
FutureW<Integer> result = FutureW.firstSuccess(FutureW.ofSupplier(()->1),ft);
               
ft.complete(10);
assertThat(result.get(), is(equalTo(1)));
Clone this wiki locally