void t_future(){ //NOTICE("fut.get"); //fut.get(); NOTICE("fut.wait"); fut.wait(); thread t1(fut_wait), t2(fut_wait), t3(fut_wait); while(true){ prom = promise<bool>(); fut = prom.get_future(); sleep(2); prom.set_value(false); sleep(3); } t1.join(); t2.join(); t3.join(); }
void calculate() { this_thread::sleep_for(chrono::milliseconds(1000)); fut=the_answer_to_life_the_universe_and_everything.get_future(); the_answer_to_life_the_universe_and_everything.set_value(42); }
callable ca( fn, boost::move( prom), ctx2); shared_ptr< thread > thrd( new thread( ca), detail::joiner() ); ctx1.reset( thrd); return t; } template< typename Fn > task< typename result_of< Fn() >::result_type > operator()( BOOST_RV_REF( Fn) fn) { typedef typename result_of< Fn() >::result_type R; BOOST_ASSERT( ! this_task::runs_in_pool() ); promise< R > prom; unique_future< R > f( prom.get_future() ); context ctx1, ctx2; task< R > t( f, ctx1); callable ca( boost::move( fn), boost::move( prom), ctx2); shared_ptr< thread > thrd( new thread( ca), detail::joiner() ); ctx1.reset( thrd); return t; } }; }} #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX #endif