static <T> ReactiveSeq<T> enqueuedAll(Consumer<? super Subscriber<T>>... subs){ final Counter c = new Counter(); c.active.set(subs.length); QueueBasedSubscriber<T> s = QueueBasedSubscriber.subscriber(c,subs.length); for(Consumer<? super Subscriber<T>> next : subs) next.accept(s); s.close(); return s.reactiveSeq(); } static <T> ReactiveSeq<T> enqueued(Queue<T> q,Consumer<? super Subscriber<T>> sub){
/** * Create a Stream that accepts data via the Subsriber passed into the supplied Consumer. * reactive-streams susbscription can be used to determine demand (or ignored and data passed * via onNext, onError) excess supply over demand is enqueued * * <pre> * {@code * ReactiveSeq<Integer> input = ReactiveSeq.enqueued(subscriber->{ * listener.onEvent(subscriber::onNext); * listener.onError(susbscriber::onError); * closeListener.onEvent(subscriber::onClose); * }); * } * </pre> * * @param sub * @param <T> * @return */ static <T> ReactiveSeq<T> enqueued(Consumer<? super Subscriber<T>> sub){ final Counter c = new Counter(); c.active.set(1); QueueBasedSubscriber<T> s = QueueBasedSubscriber.subscriber(c,1); sub.accept(s); s.close(); return s.reactiveSeq(); } static <T> ReactiveSeq<T> enqueuedAll(Consumer<? super Subscriber<T>>... subs){
/** * A potentially asynchronous merge operation where data from each publisher may arrive out of order (if publishers * are configured to publish asynchronously. * The QueueFactory parameter can be used by pull based Streams to control the maximum queued elements @see {@link QueueFactories} * Push based reactive-streams signal demand via their subscription. * * */ @Deprecated //name will be refactored to merge in the future default ReactiveSeq<T> mergeP(final QueueFactory<T> factory,final Publisher<T>... publishers) { final Counter c = new Counter(); c.active.set(publishers.length + 1); final QueueBasedSubscriber<T> init = QueueBasedSubscriber.subscriber(factory, c, publishers.length); final Supplier<Continuation> sp = () -> { subscribe(init); for (final Publisher next : publishers) { next.subscribe(QueueBasedSubscriber.subscriber(init.getQueue(), c, publishers.length)); } init.close(); return Continuation.empty(); }; final Continuation continuation = new Continuation( sp); init.addContinuation(continuation); return ReactiveSeq.fromStream(init.jdkStream()); } default ReactiveSeq<T> publishTo(Adapter<T>... adapters){
static <T> ReactiveSeq<T> enqueuedAll(Consumer<? super Subscriber<T>>... subs){ final Counter c = new Counter(); c.active.set(subs.length); QueueBasedSubscriber<T> s = QueueBasedSubscriber.subscriber(c,subs.length); for(Consumer<? super Subscriber<T>> next : subs) next.accept(s); s.close(); return s.reactiveSeq(); } static <T> ReactiveSeq<T> enqueued(Queue<T> q,Consumer<? super Subscriber<T>> sub){
/** * Create a Stream that accepts data via the Subsriber passed into the supplied Consumer. * reactive-streams susbscription can be used to determine demand (or ignored and data passed * via onNext, onError) excess supply over demand is enqueued * * <pre> * {@code * ReactiveSeq<Integer> input = ReactiveSeq.enqueued(subscriber->{ * listener.onEvent(subscriber::onNext); * listener.onError(susbscriber::onError); * closeListener.onEvent(subscriber::onClose); * }); * } * </pre> * * @param sub * @param <T> * @return */ static <T> ReactiveSeq<T> enqueued(Consumer<? super Subscriber<T>> sub){ final Counter c = new Counter(); c.active.set(1); QueueBasedSubscriber<T> s = QueueBasedSubscriber.subscriber(c,1); sub.accept(s); s.close(); return s.reactiveSeq(); } static <T> ReactiveSeq<T> enqueuedAll(Consumer<? super Subscriber<T>>... subs){
/** * A potentially asynchronous merge operation where data from each publisher may arrive out of order (if publishers * are configured to publish asynchronously. * The QueueFactory parameter can be used by pull based Streams to control the maximum queued elements @see {@link QueueFactories} * Push based reactive-streams signal demand via their subscription. * * */ @Deprecated //name will be refactored to merge in the future default ReactiveSeq<T> mergeP(final QueueFactory<T> factory,final Publisher<T>... publishers) { final Counter c = new Counter(); c.active.set(publishers.length + 1); final QueueBasedSubscriber<T> init = QueueBasedSubscriber.subscriber(factory, c, publishers.length); final Supplier<Continuation> sp = () -> { subscribe(init); for (final Publisher next : publishers) { next.subscribe(QueueBasedSubscriber.subscriber(init.getQueue(), c, publishers.length)); } init.close(); return Continuation.empty(); }; final Continuation continuation = new Continuation( sp); init.addContinuation(continuation); return ReactiveSeq.fromStream(init.jdkStream()); } default ReactiveSeq<T> publishTo(Adapter<T>... adapters){