#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) template <typename Closure> void submit(Closure & closure) { work w ((closure)); submit(boost::move(w)); } #endif void submit(void (*closure)()) { work w ((closure)); submit(boost::move(w)); } template <typename Closure> void submit(BOOST_THREAD_FWD_REF(Closure) closure) { //submit(work(boost::forward<Closure>(closure))); work w((boost::forward<Closure>(closure))); submit(boost::move(w)); } /** * \par Effects * Try to execute one task. * * \par Returns * Whether a task has been executed. * * \par Throws * Whatever the current task constructor throws or the task() throws.
*/ template <class CallableThread = join_if_joinable> class strict_scoped_thread { thread t_; struct dummy; public: BOOST_THREAD_NO_COPYABLE( strict_scoped_thread) /// non copyable /* * */ #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template <class F, class ...Args, typename = typename disable_if<is_same<typename decay<F>::type, thread>, dummy* >::type> explicit strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(Args)... args) : t_(boost::forward<F>(f), boost::forward<Args>(args)...) {} #else template <class F> explicit strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, typename disable_if<is_same<typename decay<F>::type, thread>, dummy* >::type=0) : t_(boost::forward<F>(f)) {} template <class F, class A1> strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1) : t_(boost::forward<F>(f), boost::forward<A1>(a1)) {} template <class F, class A1, class A2> strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1, BOOST_THREAD_FWD_REF(A2) a2) : t_(boost::forward<F>(f), boost::forward<A1>(a1), boost::forward<A2>(a2)) {} template <class F, class A1, class A2, class A3> strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1, BOOST_THREAD_FWD_REF(A2) a2, BOOST_THREAD_FWD_REF(A3) a3) : t_(boost::forward<F>(f), boost::forward<A1>(a1), boost::forward<A2>(a2), boost::forward<A3>(a3)) {}
return invoke(boost::move(std::get<0>(f_)), boost::move(std::get<Indices>(f_))...); } }; #else template <class Fp> class async_func { Fp f_; public: BOOST_THREAD_COPYABLE_AND_MOVABLE(async_func) typedef typename result_of<Fp()>::type result_type; BOOST_SYMBOL_VISIBLE explicit async_func(BOOST_THREAD_FWD_REF(Fp) f) : f_(boost::move(f)) {} BOOST_SYMBOL_VISIBLE async_func(BOOST_THREAD_FWD_REF(async_func) f) : f_(boost::move(f.f_)) {} result_type operator()() { return execute(); } private: result_type execute() { return f_(); }
class invoker { //typedef typename decay<Fp>::type Fpd; //typedef tuple<typename decay<Args>::type...> Argsd; //csbl::tuple<Fpd, Argsd...> f_; csbl::tuple<Fp, Args...> f_; public: BOOST_THREAD_COPYABLE_AND_MOVABLE( invoker) //typedef typename invoke_of<_Fp, _Args...>::type Rp; typedef typename result_of<Fp(Args...)>::type result_type; template <class F, class ... As> BOOST_SYMBOL_VISIBLE explicit invoker(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(As)... args) : f_(boost::forward<F>(f), boost::forward<As>(args)...) {} BOOST_SYMBOL_VISIBLE invoker(BOOST_THREAD_RV_REF(invoker) f) : f_(boost::move(BOOST_THREAD_RV(f).f_)) {} BOOST_SYMBOL_VISIBLE invoker( const invoker& f) : f_(f.f_) {} BOOST_SYMBOL_VISIBLE invoker& operator=(BOOST_THREAD_RV_REF(invoker) f) { f_ = boost::move(BOOST_THREAD_RV(f).f_);
{} void operator()() { ex.submit(funct); } private: Executor& ex; Function funct; }; /// resubmitter factory template <class Executor, class Function> resubmitter<Executor, typename decay<Function>::type> resubmit(Executor& ex, BOOST_THREAD_FWD_REF(Function) funct) { return resubmitter<Executor, typename decay<Function>::type >(ex, boost::move(funct)); } /// Wraps references to a @c Scheduler and an @c Executor providing an @c Executor that /// resubmit the function using the referenced Executor at a given @c time_point known at construction. template <class Scheduler, class Executor> class resubmit_at_executor { public: typedef typename Scheduler::clock clock; typedef typename Scheduler::work work; template <class Duration> resubmit_at_executor(Scheduler& sch, Executor& ex, chrono::time_point<clock, Duration> const& tp) : sch(sch),
/** * executor_adaptor constructor */ #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template <typename ...Args> executor_adaptor(BOOST_THREAD_RV_REF(Args) ... args) : ex(boost::forward<Args>(args)...) {} #else /** * executor_adaptor constructor */ executor_adaptor() : ex() {} template <typename A1> executor_adaptor( BOOST_THREAD_FWD_REF(A1) a1 ) : ex( boost::forward<A1>(a1) ) {} template <typename A1, typename A2> executor_adaptor( BOOST_THREAD_FWD_REF(A1) a1, BOOST_THREAD_FWD_REF(A2) a2 ) : ex( boost::forward<A1>(a1), boost::forward<A2>(a2) ) {} template <typename A1, typename A2, typename A3> executor_adaptor(