|
Boost : |
Subject: Re: [boost] Common future base class (was Re: Boost.Fiber mini-review September 4-13)
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2015-09-06 09:14:24
> The problem exist already for any library proposing a standard future
> implementation. How can this new implementation works with a standard
> implementation. This is the case for Boost.Thread, HPX, Boost.AFIO,
> Boost.Fiber, or your own implementation.
> What I meant is that we need to change the standard to be able to solve
> this problem, as the standard don't take it in account.
I believe the solution to is not so much to change (std::)future, but to
push forward 'await' instead. It already has (most) of a
future-type-agnostic synchronization mechanism specified. Granted, the
proposal will change, but I'm certain it will get into C++ in the C++17
timeframe. The 'await' allows to rewrite when_all, etc. such that it works
for any combination of input futures. Here's a sketch (sans decay, etc.):
namespace foobar
{
template <typename Future...>
requires(is_future<Future>)...
future<tuple<Future...>> when_all(Future &&... f)
{
(await f)...;
return make_tuple(std::forward<Future>(f)...);
}
}
i.e. every library which exposes its future type provides this trivial
implementation of when_all(), etc. It can consume any future from any other
place, however.
Regards Hartmut
---------------
http://boost-spirit.com
http://stellar.cct.lsu.edu
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk