[concurrency-interest] Future.isCompletedNormally Future.isCompletedAbnormally

thurstonn thurston at nomagicsoftware.com
Thu Mar 5 14:07:33 EST 2015


Martin Buchholz-3 wrote
> Even isDone is not (yet) mentioned in
> Memory Consistency Properties
> 
> in
> http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/package-summary.html
> 
> All of the is* methods would (obviously) have the same happens-before
> semantics.

But that's deliberate - isDone() can't have any specified memory consistency
rules, since 
the following **doesn't** hold:
 isDone == true iff isCompletedNormally() == true

The usefulness of isCompletedNormally() would lie exactly in this, e,g,

if (f.isCompletedNormally())
   do something  //all done
else if (waitedlongenough())
   f.cancel()
   schedule a backup/replacement execution

That would be useful, especially given that get() throws checked exceptions,
which makes the above presently very unwieldy.
isCompletedNormally should have the same memory consistency effects as a
"successful" return from f.get().  In fact, I'd prefer it be renamed to
wasSuccessful() (but what's in a name?)








--
View this message in context: http://jsr166-concurrency.10961.n7.nabble.com/Future-isCompletedNormally-Future-isCompletedAbnormally-tp12386p12399.html
Sent from the JSR166 Concurrency mailing list archive at Nabble.com.


More information about the Concurrency-interest mailing list