> On Feb. 14, 2014, 12:07 a.m., Jie Yu wrote: > > src/java/jni/org_apache_mesos_state_AbstractState.cpp, line 99 > > <https://reviews.apache.org/r/17686/diff/3/?file=470405#file470405line99> > > > > What's the reason of returning false all the time? Is that weird if > > isCancelled() returns false and a CancellationException being thrown? > > Benjamin Hindman wrote: > Java's cancellation semantics are weird IMHO, and I choose to return > false here to match them. Here's what we have to make sure: > > (1) If 'cancel' is called we should always return false since we've > started the computation and we don't know if we'll actually be able to cancel > it and we don't want too block to figure out if we should cancel it (we > should really only block in 'get'). > > (2) After 'cancel' is called 'isCancelled' only has to return true if > 'cancel' returned true. Since we returned false in 'cancel', we can return > false here. Like (1), we don't want to block to figure out if it was actually > cancelled. > > (3) After 'cancel' is called 'isDone' always has to return true ... which > is totally crazy because it seems very realistic that 'cancel' returned false > because the computation is still running! Again, we're choosing not to block > in 'cancel' or anywhere else but only block in 'get' since in practice this > is probably where most Java people will expect a blocking operation. > > There aren't anything in the semantics that say getting true for > 'isCancelled' implies you can't get a CancellationException, but we could > imagine returning an ExecutionException instead of a CancellationException if > we really thought this was going to throw people off. Likewise, we could > imagine making 'isCancelled' check 'isDiscarded' but there is a race here so > I just decided to be deterministic. > > Please let me know if something doesn't make sense or you have a > different interpretation of the Java semantics.
> (2) ... Like (1), we don't want to block to figure out if it was actually > cancelled. We don't need to block to figure out if it was actually cancelled. If future->isDiscarded(), we can return true without blocking. In the java spec, if cancel() returns false, isCancelled() is allowed to return true. > Likewise, we could imagine making 'isCancelled' check 'isDiscarded' but there > is a race here so I just decided to be deterministic. I don't understand why bother the race here. Seems that isCancelled() is totally useless in your code. What we are suggesting is: make isCancelled() a best effort check (without blocking). - Jie ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/17686/#review34443 ----------------------------------------------------------- On Feb. 18, 2014, 8:46 a.m., Benjamin Hindman wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/17686/ > ----------------------------------------------------------- > > (Updated Feb. 18, 2014, 8:46 a.m.) > > > Review request for mesos, Adam B, Ben Mahler, Ian Downes, Jie Yu, Niklas > Nielsen, TILL TOENSHOFF, Vinod Kone, and Jiang Yan Xu. > > > Repository: mesos-git > > > Description > ------- > > See summary. > > > Diffs > ----- > > src/java/jni/org_apache_mesos_state_AbstractState.cpp > 2ee0b1b631b80ec783e6bce683cdeaa77e56b2aa > src/linux/cgroups.cpp 8ac25993886f5092fe6a58abdddbbb71e02911af > src/log/catchup.cpp 59facbf9b5d065ba5066b6b443db4ee8e05ee33b > src/log/consensus.cpp b89673a3b8f233e901eaf9ae69a9979099f4eb73 > src/log/log.cpp e83f822af86a2389e2b1abab9489713cb59838c2 > src/log/recover.cpp d06e5ada714ba0e5359ff1d3381edb6d526c6ad3 > src/master/detector.cpp 7e10433013b9415ec73c388e8dc69ab0989cdbc2 > src/master/registrar.cpp 915885a160f790399e8185c28c6e6555af1ee76e > src/sasl/authenticatee.hpp f1a677f8aed0979f958e51f85e0a8210a03bd343 > src/sasl/authenticator.hpp 1478f6771b424555c34586a0d61f208dc15b0e7d > src/slave/gc.hpp 328aa315d8ebd7ea5d05b57626ea4dbfc2206270 > src/slave/gc.cpp 405350bf8f498d2e59e9e6b4c4c19b7bdaa974de > src/zookeeper/contender.cpp 6710da4e64fc0a43c1eabfc0f39fb0133c13df14 > src/zookeeper/group.cpp 793763e8312676f3b7cceb54bbad0337c8445ea7 > > Diff: https://reviews.apache.org/r/17686/diff/ > > > Testing > ------- > > make check > > > Thanks, > > Benjamin Hindman > >
