[concurrency-interest] InterruptedException-free wrappers for calls that "will never be interrupted"

Doug Lea dl at cs.oswego.edu
Wed Apr 14 06:57:05 EDT 2010


On 04/13/10 21:44, Chris Povirk wrote:

> My RPC scenario may not generalize well beyond Future.

So, what do you think of at least addressing this case,
by adding j.u.c.JoinableFuture, that basically pushes up
ForkJoinTask.join to interface level:

interface JoinableFuture<V> extends Future<V> {
     /**
      * Returns the result of the computation when it {@link #isDone is done}.
      * This method differs from {@link #get()} in that
      * abnormal completion results in {@code RuntimeException} or
      * {@code Error}, not {@code ExecutionException}. Further,
      * this method continues to wait for completion even if the
      * calling thread is interrupted.
      * @return the computed result
      */
     V join();
}

Note that this version both escalates exceptions
and ignores interrupts. ForkJoinTask requires this form.
If we want versions of methods that do only one or the other,
things get messier.

We could also retrofit FutureTask to implement JoinableFuture.
We'd need to weigh the risk that someone
out there already added method join to a FutureTask subclass,
and back up to adding a JoinableFutureTask class if we decide
to be cowardly about it. A quick check of Google code search
looking for "extends FutureTask join" doesn't find any such cases.

-Doug




More information about the Concurrency-interest mailing list