On Wed, 5 Mar 2025 23:55:52 GMT, Sunmisc Unsafe <d...@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