3#include "util/async/Error.hpp"
4#include "util/async/impl/Any.hpp"
5#include "util/async/impl/ErasedOperation.hpp"
25template <
typename RetType>
34 : operation_{std::move(operation)}
74 [[nodiscard]] std::expected<RetType, ExecutionError>
78 auto data = operation_.get();
80 return std::unexpected(std::move(
data).error());
82 if constexpr (std::is_void_v<RetType>) {
85 return std::any_cast<RetType>(std::move(
data).value());
88 }
catch (std::bad_any_cast
const& e) {
89 return std::unexpected{
90 ExecutionError(fmt::format(
"{}", std::this_thread::get_id()),
"Bad any cast")
A type-erased operation that can be executed via AnyExecutionContext.
Definition AnyOperation.hpp:26
void abort()
Abort the operation.
Definition AnyOperation.hpp:64
void invoke()
Force-invoke the operation.
Definition AnyOperation.hpp:102
AnyOperation(impl::ErasedOperation &&operation)
Construct a new type-erased Operation object.
Definition AnyOperation.hpp:33
void wait() noexcept
Wait for the operation to complete.
Definition AnyOperation.hpp:52
std::expected< RetType, ExecutionError > get()
Get the result of the operation.
Definition AnyOperation.hpp:75
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:18
Error channel type for async operation of any ExecutionContext.
Definition Error.hpp:14