RFR: WIP: add a new subclass of StructuredTaskScope that shows the finished subtasks as a Stream

Remi Forax forax at univ-mlv.fr
Fri Sep 1 14:22:46 UTC 2023


----- Original Message -----
> From: "Alan Bateman" <Alan.Bateman at oracle.com>
> To: "Rémi Forax" <forax at openjdk.org>, "loom-dev" <loom-dev at openjdk.org>
> Sent: Friday, September 1, 2023 3:30:11 PM
> Subject: Re: RFR: WIP: add a new subclass of StructuredTaskScope that shows the finished subtasks as a Stream

> On 01/09/2023 14:23, Rémi Forax wrote:
>> :
>>
>> The current implementation is not the right one, instead of introducing a new
>> method into the Flock that can wait on shutdown, threadCount == 0 and the queue
>> has a new subtask, this implementation shutdown the flock early and do not
>> implement shutdown() so it only have to check if the number of tasks is zero.
>>
>>
> One thing that could be useful is to start out in your own package and
> use it to help identify any protected methods that might need to be
> exposed to subclasses to do this themselves. SOS and SOF aren't special
> for example.

Thanks Alan,
Compare to SOS and SOF, here I want to implement my own blocking scheme which is not exactly the same as join() (or the underlying ThreadFlock.awaitAll()).

So what i need is a pair of methods await()/wakeup().
- await() is blocking until wakeup is called, and it return a boolean indicating that no thead are alive in the flock
- wakeup unblock await.

With shutdown() doing a wakeup.

So after await(), I can check if await is awake because of a shutdown(), a new subtask in the queue or because there are no more thread.

That's the hard part for me is that I do not fully understand how ThreadFlock awaitAll works. 

I also need ensureOwner() and ensureOpen() to be protected. Having a way to check the owner without checking if join() is called, given that I'm implementing a new kind of join().

> 
> Another thing that comes to mind is that you might remember the streamy
> methods we had on ES in some of the early prototypes. These were used to
> shake out issues with have a stream to a blocking source.

Those methods were only valid once join()/joinUntil() was called, so I do not think, it works the same way. Here, I want to implement a new kind of join().

> 
> -Alan

Rémi


More information about the loom-dev mailing list