StructuredTaskScope API open can use an UnaryOperator instead of a Function

Jens Lideström jens at lidestrom.se
Tue May 20 07:22:43 UTC 2025


Note that this would narrow the argument type.

For lambda arguments it would work just as good.

But if the user has an existing `Function` object that they would like 
to use as argument then that will not be possible.

This is maybe not a big disadvantage but something to take into 
consideration.

Best regards,
Jens Lideström

On 2025-05-20 09:03, Alan Bateman wrote:

> On 20/05/2025 07:53, Remi Forax wrote:
> 
>> Hello,
>> i've just taken a look to the new StructuredTaskScope API,
>> i've seen a small improvement that can be done to the API.
>> 
>> There is a method open that takes a joiner and a configuration 
>> function (a configuration builder really)
>> 
>> open(Joiner<? super T, ? extends R> joiner, Function<Configuration, 
>> Configuration> configFunction)
>> 
>> In java.util.function, there is already a type for the function that 
>> return the same type as the parameter, it's UnaryOperator,
>> so the signature of open(joiner, configFunction) can be simplified to
>> 
>> open(Joiner<? super T, ? extends R> joiner, 
>> UnaryOperator<Configuration> configFunction)
> 
> Noted.  Nicolai Parlog pointed this out recently too. It wouldn't 
> change the intended usage but would make the signature look less scary. 
> So the list to look at for the next update.
> 
> -Alan


More information about the loom-dev mailing list