use of cyclops.futurestream.FutureStream in project cyclops by aol.
the class BaseSeqTest method asyncSyncTest.
@Test
public void asyncSyncTest() {
FutureStream stream = of(1, 2, 3, 4).async().sync();
assertThat(stream.isAsync(), is(false));
}
use of cyclops.futurestream.FutureStream in project cyclops by aol.
the class BaseSeqTest method syncTest.
@Test
public void syncTest() {
FutureStream stream = of(1, 2, 3, 4).sync();
assertThat(stream.isAsync(), is(false));
}
use of cyclops.futurestream.FutureStream in project cyclops by aol.
the class BaseSeqTest method syncAndAsyncTest.
@Test
public void syncAndAsyncTest() {
FutureStream stream = of(1, 2, 3, 4).sync().async();
assertThat(stream.isAsync(), is(true));
}
use of cyclops.futurestream.FutureStream in project cyclops by aol.
the class LazyToQueue method addToQueue.
@Override
default void addToQueue(final Queue queue) {
FutureStream str = thenSync(queue::add).self(s -> {
if (this.getPopulator().isPoolingActive())
s.peekSync(v -> {
throw new CompletedException(v);
});
});
final Continuation continuation = queue.getContinuationStrategy().isBlocking() ? str.blockingContinuation(() -> {
throw new ClosedQueueException();
}) : str.runContinuation(() -> {
throw new ClosedQueueException();
});
queue.addContinuation(continuation);
}
use of cyclops.futurestream.FutureStream in project cyclops by aol.
the class LazySeqTest method shouldZipFiniteWithInfiniteSeq.
@Test
public void shouldZipFiniteWithInfiniteSeq() throws Exception {
ThreadPools.setUseCommon(false);
final ReactiveSeq<Integer> units = new LazyReact(ThreadPools.getCommonFreeThread()).iterate(1, n -> n + 1).limit(5);
// <-- MEMORY LEAK! - no auto-closing yet, so writes infinetely to it's async queue
final FutureStream<Integer> hundreds = new LazyReact(ThreadPools.getCommonFreeThread()).iterate(100, n -> n + 100);
final ReactiveSeq<String> zipped = units.zip(hundreds, (n, p) -> n + ": " + p);
assertThat(zipped.limit(5).join(), equalTo(of("1: 100", "2: 200", "3: 300", "4: 400", "5: 500").join()));
ThreadPools.setUseCommon(true);
}
Aggregations