3#include "unwrapFuture.h"
14 typename TaskParameter = async::task<T>&&>
19 async::task<T> operator()(TaskParameter t) {
21 return async::make_task(t.get());
25 auto ptrToException = [f = std::move(f)](std::exception_ptr&& e)
mutable {
27 std::rethrow_exception(e);
28 }
catch (std::exception& e) {
29 return f(std::move(e));
31 return f(std::runtime_error(
"Unknown exception"));
34 return async::make_task(std::current_exception())
37 unwrapFuture<
decltype(ptrToException), std::exception_ptr>(
38 std::move(ptrToException)));
43template <
typename Func,
typename Scheduler,
typename TaskParameter>
44struct CatchFunction<Func, void, Scheduler, TaskParameter> {
48 async::task<void> operator()(TaskParameter t) {
51 return async::make_task();
55 auto ptrToException = [f = std::move(f)](std::exception_ptr&& e)
mutable {
57 std::rethrow_exception(e);
58 }
catch (std::exception& e) {
59 return f(std::move(e));
61 return f(std::runtime_error(
"Unknown exception"));
64 return async::make_task(std::current_exception())
67 unwrapFuture<
decltype(ptrToException), std::exception_ptr>(
68 std::move(ptrToException)));
Classes that support asynchronous operations.