use of cyclops.control.Future in project cyclops by aol.
the class ZipAsyncTest method exactElements1000.
@Test
public void exactElements1000() {
AtomicLong count = new AtomicLong(0);
Future future = Future.future();
Spouts.iterate(0l, i -> i + 1l).zip(Spouts.iterate(0l, i -> i + 1l)).limit(500l).map(t -> t._1()).forEach(1000, n -> count.incrementAndGet(), e -> {
}, () -> future.complete(1));
future.get();
assertThat(count.get(), equalTo(500l));
}
use of cyclops.control.Future in project cyclops by aol.
the class ZipAsyncTest method zipErrors.
@Test
public void zipErrors() {
Future future = Future.future();
Spouts.of(1, 2, 3).zipWithPublisher(Spouts.reactiveStream(Fixtures.threeErrorsSource)).forEach(System.out::println, System.out::println, () -> future.complete(1));
future.get();
}
use of cyclops.control.Future in project cyclops by aol.
the class ExtensionOperatorsTest method testLimitLast1.
@Test
public void testLimitLast1() {
ReactiveSeq.of(1, 2, 3).forEach(2, System.out::println);
System.out.println("Hello world!");
Future result = Future.future();
Spouts.of(1, 2, 3, 4, 5).takeRight(1).collectAll(Collectors.toList()).forEachSubscribe(e -> {
System.out.println("Value recieved " + e);
result.complete(e);
// sub[0].cancel();
}, e -> {
result.completeExceptionally(e);
// sub[0].cancel();
}, () -> {
if (!result.isDone()) {
result.complete(null);
}
}).request(1l);
assertThat(result.orElse(null), equalTo(Arrays.asList(5)));
System.out.println(Spouts.of(1, 2, 3, 4, 5).takeRight(1).collectAll(Collectors.toList()).findFirst());
assertThat(Spouts.of(1, 2, 3, 4, 5).takeRight(1).collect(Collectors.toList()), equalTo(Arrays.asList(5)));
}
Aggregations