Re: java.util.concurrent.Flow with opposite direction of item flow

Dávid Karnok via Concurrency-interest <[email protected]>
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <CAAWwtm-ioAK_yxYrvwmH3gynw+iMLO3cy76ODahyztJtPqNhLg@mail.gmail.com>
>  1. Does it mean that the output of Publishers p1 and p2 appear on the
output
of processor in parallel, without delays?

No. merge/flatMap produces a Publisher and as such, its onNext is
serialized with respect to the sources. You can think of them as putting
items into a concurrent queue but only one thread is ever polling the same
queue.

> 2. Is there an opposite operation to  /processor.onNext(p1)/, when p1
wants
to stop sending data to the processor?

p1 should signal onComplete(). If you don't exactly control p1, there are
operators (such as takeUntil) and ways to intervene:

Publisher<T> p1 = ...
Processor<Object> stopP1 = PublishProcessor.create();

processor.onNext(Flowable.fromPublisher(p1).takeUntil(stopP1));

// later
stopP1.onComplete();


Alexei Kaigorodov via Concurrency-interest <
[email protected]> ezt írta (időpont: 2019. dec. 19., Cs,
17:33):

> /   Publisher<T> p1 = ...
>     Publisher<T> p2 = ...
>     Publisher<T> p3 = ...
> ...
>
> If the generators can appear dynamically, you can submit them to a
> Processor
> and identity-flatMap the sequence:
>
>     Processor<Publisher&lt;T>> processor = PublishProcessor.create();
>
>     Flowable<T> mergedDynamic = processor.flatMap(p -> p);
>
>     processor.onNext(p1);
>     processor.onNext(p2);
>   /
> 1. Does it mean that the output of Publishers p1 and p2 appear on the
> output
> of processor in parallel, without delays?
> 2. Is there an opposite operation to  /processor.onNext(p1)/, when p1 wants
> to stop sending data to the processor?
>
>
>
>
> --
> Sent from: http://jsr166-concurrency.10961.n7.nabble.com/
> _______________________________________________
> Concurrency-interest mailing list
> [email protected]
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>


-- 
Best regards,
David Karnok

_______________________________________________
Concurrency-interest mailing list
[email protected]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.