Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9711: future continuation called twice
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-02-26 17:59:07
#9711: future continuation called twice
---------------------------+----------------------
Reporter: anonymous | Owner: viboes
Type: Bugs | Status: assigned
Milestone: Boost 1.56.0 | Component: thread
Version: Boost 1.55.0 | Severity: Problem
Resolution: | Keywords: futures
---------------------------+----------------------
Comment (by viboes):
Replying to [comment:7 anonymous]:
> If you want to start the continuation in the get() of futr2 that would
mean that this will not start the continuation at all:
>
> {{{
> auto futr1 = promise1.get_future();
>
> auto futr2 = futr1.then({});
>
> promise1.set_value();
> }}}
Here you create a continuation that is asynchronously called when the
futr1 is ready and so it will be called independently of whether you get
the value of futr2 or not. You example used deferred
{{{
auto futr2 = futr.then(boost::launch::deferred, ...);
}}}
so that the continuation should be called only when you call futr2.get().
> Is this intended?
This is how I understand it. Maybe you can disagree.
> (Please note that the only get() call here is inside the continuation
itself.)
> What about this:
>
> {{{
> auto futr1 = promise1.get_future();
>
> auto futrLast = futr1.then({}).then({}).then({});
>
> promise1.set_value();
> }}}
>
> Do I always have to keep track which future is at the end of the line
and call its get()?
The last one is stored in futrLast. What i sthe problem?
> My main use-case would be to not block at all, but this way I am forced
to call get() and thus block in it.
The you must use launch::async.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9711#comment:8> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC