| 4975 | template <typename R> |
| 4976 | template <typename F> |
| 4977 | inline BOOST_THREAD_FUTURE<typename boost::result_of<F(BOOST_THREAD_FUTURE<R>)>::type> |
| 4978 | BOOST_THREAD_FUTURE<R>::then(launch policy, BOOST_THREAD_FWD_REF(F) func) { |
| 4979 | typedef typename boost::result_of<F(BOOST_THREAD_FUTURE<R>)>::type future_type; |
| 4980 | BOOST_THREAD_ASSERT_PRECONDITION(this->future_.get()!=0, future_uninitialized()); |
| 4981 | |
| 4982 | // keep state alive as we move ourself but hold the lock |
| 4983 | shared_ptr<detail::shared_state_base> sentinel(this->future_); |
| 4984 | boost::unique_lock<boost::mutex> lock(sentinel->mutex); |
| 4985 | |
| 4986 | if (underlying_cast<int>(policy) & int(launch::async)) { |
| 4987 | return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>( |
| 4988 | lock, boost::move(*this), boost::forward<F>(func) |
| 4989 | ))); |
| 4990 | } else if (underlying_cast<int>(policy) & int(launch::deferred)) { |
| 4991 | return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>( |
| 4992 | lock, boost::move(*this), boost::forward<F>(func) |
| 4993 | ))); |
| 4994 | } else if (underlying_cast<int>(policy) & int(launch::sync)) { |
| 4995 | return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_sync_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>( |
| 4996 | lock, boost::move(*this), boost::forward<F>(func) |
| 4997 | ))); |
| 4998 | #ifdef BOOST_THREAD_PROVIDES_EXECUTORS |
| 4999 | } else if (underlying_cast<int>(policy) & int(launch::executor)) { |
| 5000 | assert(this->future_->get_executor()); |
| 5001 | typedef executor Ex; |
| 5002 | Ex& ex = *(this->future_->get_executor()); |
| 5003 | return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_executor_continuation_shared_state<Ex, BOOST_THREAD_FUTURE<R>, future_type>(ex, |
| 5004 | lock, boost::move(*this), boost::forward<F>(func) |
| 5005 | ))); |
| 5006 | #endif |
| 5007 | } else if (underlying_cast<int>(policy) & int(launch::inherit)) { |
| 5008 | |
| 5009 | launch policy_ = this->launch_policy(lock); |
| 5010 | if (underlying_cast<int>(policy_) & int(launch::async)) { |
| 5011 | return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>( |
| 5012 | lock, boost::move(*this), boost::forward<F>(func) |
| 5013 | ))); |
| 5014 | } else if (underlying_cast<int>(policy_) & int(launch::deferred)) { |
| 5015 | return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>( |
| 5016 | lock, boost::move(*this), boost::forward<F>(func) |
| 5017 | ))); |
| 5018 | } else if (underlying_cast<int>(policy_) & int(launch::sync)) { |
| 5019 | return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_sync_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>( |
| 5020 | lock, boost::move(*this), boost::forward<F>(func) |
| 5021 | ))); |
| 5022 | #ifdef BOOST_THREAD_PROVIDES_EXECUTORS |
| 5023 | } else if (underlying_cast<int>(policy_) & int(launch::executor)) { |
| 5024 | assert(this->future_->get_executor()); |
| 5025 | typedef executor Ex; |
| 5026 | Ex& ex = *(this->future_->get_executor()); |
| 5027 | return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_executor_continuation_shared_state<Ex, BOOST_THREAD_FUTURE<R>, future_type>(ex, |
| 5028 | lock, boost::move(*this), boost::forward<F>(func) |
| 5029 | ))); |
| 5030 | #endif |
| 5031 | } else { |
| 5032 | return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state<BOOST_THREAD_FUTURE<R>, future_type>( |
| 5033 | lock, boost::move(*this), boost::forward<F>(func) |
| 5034 | ))); |
nothing calls this directly
no test coverage detected