| 43 | typename ...Args |
| 44 | > |
| 45 | std::future<typename impl::result_of<Function(Args...)>::type> async( |
| 46 | thread_pool& tp, |
| 47 | Function&& f, |
| 48 | Args&&... args |
| 49 | ) |
| 50 | { |
| 51 | using return_type = typename impl::result_of<Function(Args...)>::type; |
| 52 | using task_type = std::packaged_task<return_type()>; |
| 53 | auto task = std::make_shared<task_type>(std::bind(std::forward<Function>(f), std::forward<Args>(args)...)); |
| 54 | auto ret = task->get_future(); |
| 55 | tp.add_task_by_value([task]() {(*task)();}); |
| 56 | return ret; |
| 57 | } |
| 58 | |
| 59 | // ---------------------------------------------------------------------------------------- |
| 60 | |