[cpp-threads] Asynchronous Function Proposal
Lawrence Crowl
Lawrence at Crowl.org
Sat Jun 13 05:06:34 BST 2009
On 6/5/09, Herb Sutter <hsutter at microsoft.com> wrote:
> > > - We shouldn't propose a third future type. This one should
> > > return unique_future (and that and shared_future should be
> > > fixed if deemed necessary). Note that this fixes a usability
> > > issue with the current proposal, namely that the user can't
> > > put the result in a shared_future if copying is required.
> >
> > Can you provide a use case for why this flexibility is helpful?
> > After all, the original call was single-point as well.
>
> I don't understand that last part. Of course there's a single
> call site; you always start a function (and now async task)
> in one place. But of course there can be multiple consumers of
> the result of the computation; you often use the result (and now
> future<result>) in multiple places.
To use the result in multiple places in sequential code, you must
store the function result in a variable and then copy it around. The
situation is no different with a single-invocation async_future::get.
--
Lawrence Crowl
More information about the cpp-threads
mailing list