| 71 | typename R = typename result_of<F()>::type, |
| 72 | typename std::enable_if<!std::is_void<R>::value, int>::type = 0> |
| 73 | auto execute(F&& f) |
| 74 | -> decltype(dispatch(process, std::function<R()>(std::forward<F>(f)))) |
| 75 | { |
| 76 | // NOTE: Currently we cannot pass a mutable lambda into `dispatch()` |
| 77 | // because it would be captured by copy, so we convert `f` into a |
| 78 | // `std::function` to bypass this restriction. |
| 79 | return dispatch(process, std::function<R()>(std::forward<F>(f))); |
| 80 | } |
| 81 | |
| 82 | // NOTE: This overload for `void` returns `Future<Nothing>` so we can |
| 83 | // chain. This follows the same behavior as `async()`. |