> On Feb. 8, 2014, 2:36 a.m., Vinod Kone wrote: > > 3rdparty/libprocess/include/process/future.hpp, lines 569-572 > > <https://reviews.apache.org/r/17685/diff/2/?file=470399#file470399line569> > > > > Why are these static?
Because they're used in places where we don't have a reference to the promise but just have the future. > On Feb. 8, 2014, 2:36 a.m., Vinod Kone wrote: > > 3rdparty/libprocess/include/process/future.hpp, line 598 > > <https://reviews.apache.org/r/17685/diff/2/?file=470399#file470399line598> > > > > Why did this ever not discard the underlying future? The semantics are tricky here, we don't discard the promise as we don't want to give the illusion that any computation hasn't started (or possibly finished) in the event that computation is "visible" by other means. I updated this TODO with a comment saying as much. Interestingly, I had originally called discard when the promise was cleaned up because it was closer to the original semantics and made for less code changes necessary, but this really isn't the right semantics. > On Feb. 8, 2014, 2:36 a.m., Vinod Kone wrote: > > 3rdparty/libprocess/include/process/future.hpp, lines 643-648 > > <https://reviews.apache.org/r/17685/diff/2/?file=470399#file470399line643> > > > > I'm a bit confused. When you say "shouldn't get called" is the onus on > > the user to not call it or do we programmatically prevent it? In other > > words, can we a use a boolean "associated" to enforce the semantics? > > > > also, s/promises/promise's/ Yes, calling associate twice is a bug. We have never caught this, hence this laid out TODO. I'll be fixing this in some upcoming reviews. > On Feb. 8, 2014, 2:36 a.m., Vinod Kone wrote: > > 3rdparty/libprocess/include/process/future.hpp, line 819 > > <https://reviews.apache.org/r/17685/diff/2/?file=470399#file470399line819> > > > > curious why you need "typename" here? Because I'm getting a type, not a member. > On Feb. 8, 2014, 2:36 a.m., Vinod Kone wrote: > > 3rdparty/libprocess/include/process/future.hpp, line 963 > > <https://reviews.apache.org/r/17685/diff/2/?file=470399#file470399line963> > > > > How about > > > > result = data->discard = !data->discard && data->state == PENDING; > > > > Is that too complicated? Yeah, I think the 'if' is cleaner. > On Feb. 8, 2014, 2:36 a.m., Vinod Kone wrote: > > 3rdparty/libprocess/src/tests/io_tests.cpp, line 271 > > <https://reviews.apache.org/r/17685/diff/2/?file=470403#file470403line271> > > > > Is the assumption here that that the pipe buffer size is definitely > > greater than 128 bytes? Added a CHECK_LT. > On Feb. 8, 2014, 2:36 a.m., Vinod Kone wrote: > > 3rdparty/libprocess/src/tests/process_tests.cpp, line 269 > > <https://reviews.apache.org/r/17685/diff/2/?file=470404#file470404line269> > > > > why await? is the future not discarded synchronously? Better to be more liberal in tests and let implementations change under the covers! There is nothing in the semantics that says calling Promise::discard synchronously discards up a chain, hence the AWAIT. > On Feb. 8, 2014, 2:36 a.m., Vinod Kone wrote: > > 3rdparty/libprocess/src/tests/process_tests.cpp, line 305 > > <https://reviews.apache.org/r/17685/diff/2/?file=470404#file470404line305> > > > > ASSERT on the return value? I like it! I did it for the other ones too. - Benjamin ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/17685/#review33970 ----------------------------------------------------------- On Feb. 18, 2014, 8:43 a.m., Benjamin Hindman wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/17685/ > ----------------------------------------------------------- > > (Updated Feb. 18, 2014, 8:43 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 > ------- > > Previously, invoking Future::discard caused a future to transition > into the DISCARDED state which meant that any callbacks associated wit > such a transition (i.e., Future::onAny, Future::onDiscarded) got > executed _even if the computation associated with the future had not > yet completed_! This meant certain patterns where difficult if not all > together impossible. Consider: > > ExpensiveResource* resource = new ExpensiveResource(); > > Future<int> future = function() > .then([=] () { ... *resource ...; }) > .onDiscarded([=] () { delete resource; }); > > future.discard(); > > In the above code, it's possible that the onDiscarded lambda would > execute _concurrently_ with the lambda in the then! With the new > semantics, a discard is more advisorial: rather than transition a > future it instead allows a subsequent computation to decide whether or > not to cancel (or even begin) some computation. For example, the > Future::then implementation uses the "discard" information to decide > whether or not to execute the next lambda after the previous future > has been satisfied. > > A few new helpers have been added to support this refactor: > > Future::onDiscard(callback): > > Adds a callback for when Future::discard was executed on this future. > > Future::hasDiscard(): > > Checks to see if Future::discard was executed on this future. > > Promise::discard(): > > Transitions this promises underlying future to DISCARDED. > > > Diffs > ----- > > 3rdparty/libprocess/3rdparty/stout/tests/os/signals_tests.cpp > 66caa0490189cb1aff3af1631fbcf7150658b6cc > 3rdparty/libprocess/include/process/collect.hpp > ff8ab341a588d26f9678aea7f53e892d292725ec > 3rdparty/libprocess/include/process/deferred.hpp > a25080f7cfc164108e89660d4c38de8b290aee02 > 3rdparty/libprocess/include/process/future.hpp > aaf17af2eef0f1bf7062aa04469f1fa27bb4cfbe > 3rdparty/libprocess/include/process/protobuf.hpp > 7500601026a58c95325ffe4410a161d59ff7817e > 3rdparty/libprocess/src/process.cpp > 7bf2d70c59455f52b26374f78198c5c7dc0a883b > 3rdparty/libprocess/src/tests/http_tests.cpp > 15e72a1857815347e13210b44dca14bdcc16adfa > 3rdparty/libprocess/src/tests/io_tests.cpp > c0ffe759408b75de442fdd0c0047d286534b2ebc > 3rdparty/libprocess/src/tests/process_tests.cpp > eb1fd22679c7390f43ce9fb04c8e8771077d907a > > Diff: https://reviews.apache.org/r/17685/diff/ > > > Testing > ------- > > make check > > > Thanks, > > Benjamin Hindman > >
