DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Add Futures.getOrCancel #1391

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Consider adding something like:

public static <T> T getOrCancel(Future<T> future) throws ExecutionException, 
InterruptedException {
    try {
        return future.get();
    } catch (InterruptedException e) {
        future.cancel(true);
        throw e;
    }
}

And a version with timeout too.

Original issue reported on code.google.com by Ash2kk@gmail.com on 30 Apr 2013 at 8:56

GoogleCodeExporter commented 9 years ago

Original comment by wasserman.louis on 30 Apr 2013 at 3:19

GoogleCodeExporter commented 9 years ago
I searched for it but didn't find. Anyway, what i propose is different from the 
issue 1068. The idea is to cancel the future (with interruption) in case of 
interruption. Certainly the method name can be different.

Original comment by Ash2kk@gmail.com on 30 Apr 2013 at 5:36

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:12

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08