[Boost-bugs] [Boost C++ Libraries] #11192: boost::future<>::then() with an executor doesn't compile when the callback returns a future

Subject: [Boost-bugs] [Boost C++ Libraries] #11192: boost::future<>::then() with an executor doesn't compile when the callback returns a future
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-04-16 23:38:01


#11192: boost::future<>::then() with an executor doesn't compile when the callback
returns a future
-----------------------------------------+----------------------
 Reporter: konrad.zemek@… | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
  Version: Boost 1.58.0 | Severity: Problem
 Keywords: future then executor nested |
-----------------------------------------+----------------------
 As noted in the title, when the scheduler overload of
 {{{boost::future<>::then()}}} is used, and the callback given returns a
 future, the code doesn't compile.

 I'm observing this behavior using Boost 1.58 beta 1.

 The minimal code to reproduce:
 {{{#!c++
 #define BOOST_THREAD_VERSION 4
 #define BOOST_THREAD_PROVIDES_EXECUTORS

 #include <boost/thread.hpp>
 #include <boost/thread/executor.hpp>
 #include <boost/thread/thread_pool.hpp>

 boost::future<void> p(boost::future<void>) {
     return boost::make_ready_future();
 }

 int main() {
     // compiles
     boost::make_ready_future().then(&p);

     boost::basic_thread_pool executor;
     // doesn't compile
     boost::make_ready_future().then(executor, &p);
 }
 }}}

 I'm getting the following error messages when compiling with GCC 4.9.2:
 {{{
 In file included from /usr/include/boost/thread.hpp:24:0,
                  from example.cpp:4:
 /usr/include/boost/thread/future.hpp: In instantiation of
 'boost::future<Rp>
 boost::detail::make_future_executor_continuation_shared_state(Ex&,
 boost::unique_lock<boost::mutex>&, F&&, Fp&&) [with Ex =
 boost::executors::basic_thread_pool; F = boost::future<void>; Rp =
 boost::future<void>; Fp = boost::future<void> (*)(boost::future<void>)]':
 /usr/include/boost/thread/future.hpp:4628:12: required from
 'boost::future<typename boost::result_of<F(boost::future<R>)>::type>
 boost::future<R>::then(Ex&, F&&) [with Ex =
 boost::executors::basic_thread_pool; F = boost::future<void>
 (*)(boost::future<void>); R = void; typename
 boost::result_of<F(boost::future<R>)>::type = boost::future<void>]'
 example.cpp:18:49: required from here
 /usr/include/boost/thread/future.hpp:1629:13: error:
 'boost::future<boost::future<R> >::future(boost::future<boost::future<R>
>::future_ptr) [with R2 = void; boost::future<boost::future<R>
>::future_ptr =
 boost::shared_ptr<boost::detail::shared_state<boost::future<void> > >]' is
 private
              BOOST_THREAD_FUTURE(future_ptr a_future):
              ^
 In file included from /usr/include/boost/thread.hpp:24:0,
                  from example.cpp:4:
 /usr/include/boost/thread/future.hpp:4531:37: error: within this context
      return BOOST_THREAD_FUTURE<Rp>(h);
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11192>
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:18 UTC