> On Feb. 6, 2014, 11:41 p.m., Ben Mahler wrote:
> > 3rdparty/libprocess/src/process.cpp, line 3618
> > <https://reviews.apache.org/r/17685/diff/2/?file=470401#file470401line3618>
> >
> >     We're thinking we can avoid the friend function by having a wrapper 
> > continuation for discard that takes a 'Shared' promise, and we also pass a 
> > 'Shared' promise in the watcher data. This avoids the issue with the 
> > promise being deleted by the watcher.
> >     
> >     Does this make sense?
> 
> Benjamin Hindman wrote:
>     I had tried this approach before but I didn't like the idea of actually 
> _sharing_ a Promise via a shared_ptr. Other uses of shared_ptr with Promise 
> are supposed to be "owned/unique" (i.e., there won't be the possibility of 
> two threads accessing the Promise* at the same time).

Can we at least have a TODO to kill the friend function? Seems to be an 
unfortunate approach and it will not generalize outside of libprocess.


> On Feb. 6, 2014, 11:41 p.m., Ben Mahler wrote:
> > 3rdparty/libprocess/src/process.cpp, lines 1627-1628
> > <https://reviews.apache.org/r/17685/diff/2/?file=470401#file470401line1627>
> >
> >     It doesn't look like this discard will be noticed by those holding the 
> > Promise for this, and hence the response will never transition out of 
> > pending. Can you double check this?
> 
> Benjamin Hindman wrote:
>     Why wouldn't the discard be noticed? We have the future here not the 
> promise, and discard from the promise will propagate even through an 
> associate (if that was your concern). I did notice, however, that there was a 
> race cleaning up the pipes from a Response, so I fixed that and left this 
> issue opened.

We were thinking more about the discard from the future propagating inwards, 
but looking again it looks ok because it will propagate inwards due to the 
associate call in ProcessBase::visit. Feel free to drop! Glad you noticed the 
race though.


- Ben


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17685/#review33824
-----------------------------------------------------------


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
> 
>

Reply via email to