Async++ unknown
Async (co_await/co_return) code for C++
Loading...
Searching...
No Matches
policy.h
1#pragma once
2#include <exception>
3#include <functional>
4#include <utility>
5
6namespace asyncpp {
18 std::function<void()> handler;
19
25 static exception_policy handle(std::function<void()> cbfn) { return exception_policy{std::move(cbfn)}; }
26 };
27 inline const exception_policy exception_policy::terminate = {[]() { std::terminate(); }};
28 inline const exception_policy exception_policy::ignore = {};
29} // namespace asyncpp
Exception policy for e.g. fire and forget tasks.
Definition policy.h:16
std::function< void()> handler
Handler method to invoke if an exception is thrown.
Definition policy.h:18
static exception_policy handle(std::function< void()> cbfn)
Call the specified method on exception. The callback is called within the catch block.
Definition policy.h:25
static const exception_policy ignore
Noop that ignores the thrown exception. The coroutine ends at the throw point and the stack frame is ...
Definition policy.h:23
static const exception_policy terminate
The default terminate handler. Calls std::terminate() and usually ends the program.
Definition policy.h:21