You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mesos.apache.org by "Jie Yu (JIRA)" <ji...@apache.org> on 2014/03/03 21:18:21 UTC

[jira] [Updated] (MESOS-980) Revisit Future discard semantics to enforce that transitions occur through a Promise.

     [ https://issues.apache.org/jira/browse/MESOS-980?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jie Yu updated MESOS-980:
-------------------------

    Fix Version/s: 0.19.0

> Revisit Future discard semantics to enforce that transitions occur through a Promise.
> -------------------------------------------------------------------------------------
>
>                 Key: MESOS-980
>                 URL: https://issues.apache.org/jira/browse/MESOS-980
>             Project: Mesos
>          Issue Type: Improvement
>          Components: libprocess
>            Reporter: Benjamin Mahler
>            Assignee: Benjamin Hindman
>             Fix For: 0.19.0
>
>
> 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.



--
This message was sent by Atlassian JIRA
(v6.2#6252)