26template <
class CompletionToken,
typename T>
28 template <
typename Initiation,
typename CompletionHandler,
typename... Args>
29 static void initiate(Initiation&& initiation, CompletionHandler&& handler, Args&&... args) {
30 static_assert(std::is_invocable_v<CompletionHandler, T> || std::is_invocable_v<CompletionHandler, T&>);
32 std::forward<Initiation>(initiation),
33 std::forward<CompletionHandler>(handler),
34 std::forward<Args>(
args)...
39template <
typename T,
typename Initiation,
typename CompletionToken,
typename... Args>
40auto asyncInitiate(Initiation&& initiation, CompletionToken&& token, Args&&... args) {
42 std::forward<Initiation>(initiation),
43 std::forward<CompletionToken>(token),
44 std::forward<Args>(
args)...
64 template <
typename Initiation,
typename... Args>
66 std::promise<T> promise;
67 auto future = promise.get_future();
69 std::forward<Initiation>(initiation),
70 [p = std::move(promise)](T& result)
mutable { p.set_value(std::move(result)); },
71 std::forward<Args>(
args)...
94 template <
typename Initiation,
typename... Args>
96 return [initiation = std::forward<Initiation>(initiation),
97 argsPack = std::make_tuple(std::forward<Args>(
args)...)](
auto&& token)
mutable {
99 [&](
auto&&... argsInner) {
101 std::move(initiation),
102 std::forward<
decltype(token)>(token),
103 std::forward<
decltype(argsInner)>(argsInner)...
129 template <
typename Initiation,
typename... Args>
132 std::forward<Initiation>(initiation),
136 std::forward<Args>(
args)...
constexpr UseDetachedToken useDetached
Detached completion token object.
constexpr UseDeferredToken useDeferred
Deferred completion token object.
auto asyncInitiate(Initiation &&initiation, CompletionToken &&token, Args &&... args)
constexpr UseFutureToken useFuture
Future completion token object.
static UA_LogCategory const char va_list args
static auto initiate(Initiation &&initiation, UseDeferredToken, Args &&... args)
static auto initiate(Initiation &&initiation, UseDetachedToken, Args &&... args)
static auto initiate(Initiation &&initiation, UseFutureToken, Args &&... args)
static void initiate(Initiation &&initiation, CompletionHandler &&handler, Args &&... args)
Deferred completion token type.
Detached completion token type.
Future completion token type.