Re: java.util.concurrent.Flow with opposite direction of item flow
Alexei Kaigorodov via Concurrency-interest <[email protected]>
| Newsgroups | gmane.comp.java.jsr.166-concurrency |
|---|---|
| Message-ID | <[email protected]> |
/I don't see why one would expect symmetry between consumers and producers./ This symmetry stems from the original synchronous interface: when communicating with BlockingQueue, both consumers and producers are callers of the methods of the queue (take() and put(), respectively). When a synchronous interface is converted to asynchronous, callers are transformed to subscribers, and callees are transformed to publishers. So producers and consumers become subscribers, and the queue becomes Publisher of 2 different kinds: Flow.Publisher and ReverseFlow.Publisher. Since the signatures of the methods put() and take() are different, the resulting asynchronous interfaces are different: when all the preparations like subscribe() and request() are done and actual transmission of information can be performed, it is always done by the publisher side, and in our case the publisher side is the queue on both ends. So to move information from producer to the queue, the queue calls ReverseFlow.Subscriber.remove(), and to move information from the queue to consumer, the queue calls Flow.Subscriber.onNext(item). -- Sent from: http://jsr166-concurrency.10961.n7.nabble.com/ _______________________________________________ Concurrency-interest mailing list [email protected] http://cs.oswego.edu/mailman/listinfo/concurrency-interest