| 66 | typename ...Args |
| 67 | > |
| 68 | std::future<typename impl::result_of<Function(Args...)>::type> async( |
| 69 | thread_pool& tp, |
| 70 | Function&& f, |
| 71 | Args&&... args |
| 72 | ) |
| 73 | { |
| 74 | auto prom = std::make_shared<std::promise<typename impl::result_of<Function(Args...)>::type>>(); |
| 75 | std::future<typename impl::result_of<Function(Args...)>::type> ret = prom->get_future(); |
| 76 | using bind_t = decltype(std::bind(std::forward<Function>(f), std::forward<Args>(args)...)); |
| 77 | auto fun = std::make_shared<bind_t>(std::bind(std::forward<Function>(f), std::forward<Args>(args)...)); |
| 78 | tp.add_task_by_value([fun, prom]() |
| 79 | { |
| 80 | try |
| 81 | { |
| 82 | impl::call_prom_set_value(*prom, *fun, impl::selector<typename impl::result_of<Function(Args...)>::type>()); |
| 83 | } |
| 84 | catch(...) |
| 85 | { |
| 86 | prom->set_exception(std::current_exception()); |
| 87 | } |
| 88 | }); |
| 89 | return ret; |
| 90 | } |
| 91 | |
| 92 | // ---------------------------------------------------------------------------------------- |
| 93 |
nothing calls this directly
no test coverage detected