RFR: 8319447: Improve performance of delayed task handling [v6]
Alan Bateman
alanb at openjdk.org
Thu Mar 6 14:36:57 UTC 2025
On Wed, 5 Mar 2025 23:55:52 GMT, Sunmisc Unsafe <duke at openjdk.org> wrote:
>> src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 3741:
>>
>>> 3739: public <V> ForkJoinTask<V> submitWithTimeout(Callable<V> callable,
>>> 3740: long timeout, TimeUnit unit,
>>> 3741: Consumer<ForkJoinTask<V>> timeoutAction) {
>>
>> I wonder if the variance of the Consumer to this method should be more permissible. Something like:
>>
>> public <V> ForkJoinTask<V> submitWithTimeout(Callable<V> callable,
>> long timeout, TimeUnit unit,
>> Consumer<? super ForkJoinTask<? extends V>> timeoutAction) {
>
> Maybe it's worth using java.time.Duration, although it doesn't fit into the API very elegantly.
> I wonder if the variance of the Consumer to this method should be more permissible. Something like:
>
> public ForkJoinTask submitWithTimeout(Callable callable, long timeout, TimeUnit unit, Consumer<? super ForkJoinTask<? extends V>> timeoutAction) {
I think this is a good point but it might be more practical to limit it to just a contravariant Consumer, as in ` Consumer<? super ForkJoinTask<V>>`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23702#discussion_r1983469247
More information about the core-libs-dev
mailing list