| 19 | */ |
| 20 | template <typename Func> |
| 21 | TFuture<TFutureType<TFunctionResult<Func>>> Async(Func&& func, IThreadPool& queue) { |
| 22 | auto promise = NewPromise<TFutureType<TFunctionResult<Func>>>(); |
| 23 | auto lambda = [promise, func = std::forward<Func>(func)]() mutable { |
| 24 | NImpl::SetValue(promise, func); |
| 25 | }; |
| 26 | queue.SafeAddFunc(std::move(lambda)); |
| 27 | |
| 28 | return promise.GetFuture(); |
| 29 | } |
| 30 | |
| 31 | } |