From 45510facc743aa348e501642ce3d607d12dc7cfc Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sun, 1 Feb 2015 14:56:52 +0100 Subject: [PATCH] unwrapped future must forward the continuation to the wrapped future. Related to #10964. --- include/boost/thread/future.hpp | 11 ++++++++++- test/test_10964.cpp | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/boost/thread/future.hpp b/include/boost/thread/future.hpp index 2dae3523..b6b0e5f7 100644 --- a/include/boost/thread/future.hpp +++ b/include/boost/thread/future.hpp @@ -195,7 +195,7 @@ namespace boost } #endif #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION - void set_continuation_ptr(continuation_ptr_type continuation, boost::unique_lock& lock) + virtual void set_continuation_ptr(continuation_ptr_type continuation, boost::unique_lock& lock) { continuation_ptr= continuation; if (done) { @@ -4718,6 +4718,15 @@ namespace detail boost::unique_lock lk(this->mutex); return parent_value(lk).get(); } +#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION + typedef shared_ptr continuation_ptr_type; + + virtual void set_continuation_ptr(continuation_ptr_type continuation, boost::unique_lock& lock) + { + boost::unique_lock lk(parent.future_->mutex); + parent.future_->set_continuation_ptr(continuation, lk); + } +#endif }; template diff --git a/test/test_10964.cpp b/test/test_10964.cpp index de82aebd..b8cc7b5c 100644 --- a/test/test_10964.cpp +++ b/test/test_10964.cpp @@ -29,6 +29,10 @@ struct TestCallback } }; +void p1() +{ +} + int main() { #if ! defined BOOST_NO_CXX11_DECLTYPE && ! defined BOOST_NO_CXX11_AUTO_DECLARATIONS @@ -62,6 +66,11 @@ int main() TestCallback()).unwrap().then(TestCallback()).get(); } std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; + { + boost::future f = boost::async(p1); + f.then( + TestCallback()).unwrap().then(TestCallback()).get(); + } #endif return 0; }