use of cyclops.futurestream.LazyReact in project cyclops by aol.
the class AnyJavaslangMTest method javaslangCyclops.
@Test
public void javaslangCyclops() {
Lists.forEach2(List.of(1, 2, 3), a -> List.range(0, a), this::add);
Options.forEach2(Option.none(), a -> Option.<Integer>some(a + 1), this::add);
Option.some(1).flatMap(a -> Option.some(a + 1).map(b -> add(a, b)));
Array.of(1, 2, 3, 4).flatMap(i -> new LazyReact().range(i, 10)).forEach(System.out::println);
ReactiveSeq.of(1, 2, 3, 4).concatMap(i -> Stream.iterate(1, a -> a + 1).take(i)).map(i -> i + 2);
}
use of cyclops.futurestream.LazyReact in project cyclops by aol.
the class ReactPoolTest method testUnbounded.
@Test
public void testUnbounded() {
ReactPool<LazyReact> pool = ReactPool.unboundedPool(asList(new LazyReact(), new LazyReact()));
List<String> result = pool.react((er) -> er.ofAsync(() -> "hello", () -> "world").block());
pool.populate(new LazyReact());
assertThat(result.size(), is(2));
}
use of cyclops.futurestream.LazyReact in project cyclops by aol.
the class PushableStreamTest method testLazyFutureStreamTopicQueueFactory.
@Test
public void testLazyFutureStreamTopicQueueFactory() {
MultipleStreamSource<Integer> multi = StreamSource.ofMultiple(QueueFactories.boundedQueue(100));
FutureStream<Integer> pushable = multi.futureStream(new LazyReact());
multi.getInput().offer(100);
multi.getInput().close();
assertThat(pushable.collect(Collectors.toList()), hasItem(100));
}
use of cyclops.futurestream.LazyReact in project cyclops by aol.
the class PushableStreamTest method testLazyFutureStreamTopic.
@Test
public void testLazyFutureStreamTopic() {
MultipleStreamSource<Integer> multi = StreamSource.ofMultiple();
FutureStream<Integer> pushable = multi.futureStream(new LazyReact());
multi.getInput().offer(100);
multi.getInput().close();
assertThat(pushable.collect(Collectors.toList()), hasItem(100));
}
use of cyclops.futurestream.LazyReact in project cyclops by aol.
the class PushableStreamTest method testLazyFutureStreamTopicBackPressure.
@Test
public void testLazyFutureStreamTopicBackPressure() {
MultipleStreamSource<Integer> multi = StreamSource.ofMultiple(2);
FutureStream<Integer> pushable = multi.futureStream(new LazyReact());
multi.getInput().offer(100);
multi.getInput().close();
assertThat(pushable.collect(Collectors.toList()), hasItem(100));
}
Aggregations