| 89 | */ |
| 90 | template<typename Functor> |
| 91 | auto schedule( Functor&& f, const fc::time_point& when, |
| 92 | const char* desc FC_TASK_NAME_DEFAULT_ARG, priority prio = priority()) -> fc::future<decltype(f())> { |
| 93 | typedef decltype(f()) Result; |
| 94 | fc::task<Result,sizeof(Functor)>* tsk = |
| 95 | new fc::task<Result,sizeof(Functor)>( fc::forward<Functor>(f), desc ); |
| 96 | fc::future<Result> r(fc::shared_ptr< fc::promise<Result> >(tsk,true) ); |
| 97 | async_task(tsk,prio,when); |
| 98 | return r; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * This method will cancel all pending tasks causing them to throw cmt::error::thread_quit. |