RFR: 8284199: Implementation of Structured Concurrency (Incubator)

Alan Bateman alanb at openjdk.java.net
Tue May 24 10:07:57 UTC 2022


On Mon, 23 May 2022 21:09:24 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> This is the implementation of JEP 428: Structured Concurrency (Incubator).
>> 
>> This is a non-final API that provides a gentle on-ramp to structure a task as a family of concurrent subtasks, and to coordinate the subtasks as a unit.
>
> src/jdk.incubator.concurrent/share/classes/jdk/incubator/concurrent/StructuredTaskScope.java line 88:
> 
>> 86:  * {@code join} method after forking.
>> 87:  *
>> 88:  * <p> StructuredTaskScope defines the {@link #shutdown() shutdown} method to shut down a
> 
> This sentence, because of the place where it appears, is a bit confusing. So far we only know about the fact that a scope has an owner thread. So it seems odd that shutdown could be called _while_ the owner thread is waiting on a `join`. Of course, then you read what's next, and you discover that: (a) shutdown might be called by a custom scope subclass and that (b) shutdown is confined to the threads contained in this task scope - but this definition is only given much later.

I see your point. The intention is to introduce all the public methods before introducing the subclasses or policies. I think I can adjust this sentence to make it clear that a subtask may call shutdown while the owner is waiting in join.

> src/jdk.incubator.concurrent/share/classes/jdk/incubator/concurrent/StructuredTaskScope.java line 353:
> 
>> 351:      *
>> 352:      * <p> The {@code handleComplete} method should be thread safe. It may be
>> 353:      * invoked by several threads at around the same.
> 
> Something is missing? E.g. "at around the same TIME" ? (I'd suggest just using "concurrently")

Thanks, it was supposed to say "around the same time" but saying "concurrently" would be better.

> src/jdk.incubator.concurrent/share/classes/jdk/incubator/concurrent/StructuredTaskScope.java line 376:
> 
>> 374:      *
>> 375:      * <p> If this task scope is {@linkplain #shutdown() shutdown} (or in the process
>> 376:      * of shutting down) then {@code fork} returns a Future representing a {@link
> 
> Future in plaintext?

Yes, Daniel also pointed this point that there are a few uses of "StructuredTaskScope" that should also use {@code ...}.

-------------

PR: https://git.openjdk.java.net/jdk/pull/8787


More information about the core-libs-dev mailing list