3#include "util/async/Error.hpp"
4#include "util/async/impl/ErasedOperation.hpp"
24template <
typename RetType>
33 : operation_{std::move(operation)}
73 [[nodiscard]] std::expected<RetType, ExecutionError>
77 auto data = operation_.get();
79 return std::unexpected(std::move(
data).error());
81 if constexpr (std::is_void_v<RetType>) {
84 return std::any_cast<RetType>(std::move(
data).value());
87 }
catch (std::bad_any_cast
const& e) {
88 return std::unexpected{
89 ExecutionError(fmt::format(
"{}", std::this_thread::get_id()),
"Bad any cast")
A type-erased operation that can be executed via AnyExecutionContext.
Definition AnyOperation.hpp:25
void abort()
Abort the operation.
Definition AnyOperation.hpp:63
void invoke()
Force-invoke the operation.
Definition AnyOperation.hpp:101
AnyOperation(impl::ErasedOperation &&operation)
Construct a new type-erased Operation object.
Definition AnyOperation.hpp:32
void wait() noexcept
Wait for the operation to complete.
Definition AnyOperation.hpp:51
std::expected< RetType, ExecutionError > get()
Get the result of the operation.
Definition AnyOperation.hpp:74
Definition ErasedOperation.hpp:15
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:56
This namespace implements an async framework built on top of execution contexts.
Definition AnyExecutionContext.hpp:17
Error channel type for async operation of any ExecutionContext.
Definition Error.hpp:19