[concurrency-interest] Flow/SubmissionPublisher review

Doug Lea dl at cs.oswego.edu
Fri Sep 25 19:41:09 EDT 2015


On 09/24/2015 04:13 AM, Dávid Karnok wrote:
> Hello. Since the class(es) and the JEPS have been updated recently, I'dlike to
> review them again:

Thanks!

>
> ---------------
>
> http://openjdk.java.net/jeps/266
>
> "Also, one method in class |Flow |might benefit from additional supportin
> |java.util.streams|, but it is usable as-is."
>
> I don't see any j.u.s.Stream-related methodsin v1.28 @

As Paul mentioned, these got triaged out at least in the near term.
Without further j.u.s.Stream integration, the implementation
options are either to wait for publisher to complete, or to
treat as an IO-like item-by-item blocking stream,
neither of which are what people normally want or expect.
We felt that it was better not to introduce this or
related method into jdk yet until something better can be done.

> Lines 89-90:
>
>   *     periodicTask = scheduler.scheduleAtFixedRate(
>   *       () -> submit(supplier.get()), 0, period, unit);
>
> Correct me if I'm wrong, but this may leak 'this' from the constructor and
> submit may end up being called before the constructor sealed the final fields.
>

I would ordinarily agree that an example that starts a service or
thread in a constructor is too delicate for a javadoc example.
But this usage is convenient and OK because of the intrinsic
properties of ScheduledThreadPoolExecutor (all writes before
first thread creation happen-before reads by that thread, etc).

> Line 830: consume() ...
> What I'd do is to call
>
> status.whenComplete((v, e) -> subscription.cancel());

Good idea; thanks!

-Doug





More information about the Concurrency-interest mailing list