Search in sources :

Example 1 with CompletedException

use of com.oath.cyclops.internal.react.async.future.CompletedException 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);
}
Also used : Consumer(java.util.function.Consumer) Queue(com.oath.cyclops.async.adapters.Queue) ClosedQueueException(com.oath.cyclops.async.adapters.Queue.ClosedQueueException) Executor(java.util.concurrent.Executor) LazyReact(cyclops.futurestream.LazyReact) Map(java.util.Map) FutureStream(cyclops.futurestream.FutureStream) CompletedException(com.oath.cyclops.internal.react.async.future.CompletedException) Function(java.util.function.Function) CompletedException(com.oath.cyclops.internal.react.async.future.CompletedException) ClosedQueueException(com.oath.cyclops.async.adapters.Queue.ClosedQueueException) FutureStream(cyclops.futurestream.FutureStream)

Aggregations

Queue (com.oath.cyclops.async.adapters.Queue)1 ClosedQueueException (com.oath.cyclops.async.adapters.Queue.ClosedQueueException)1 CompletedException (com.oath.cyclops.internal.react.async.future.CompletedException)1 FutureStream (cyclops.futurestream.FutureStream)1 LazyReact (cyclops.futurestream.LazyReact)1 Map (java.util.Map)1 Executor (java.util.concurrent.Executor)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1