22#include "util/async/Concepts.hpp"
23#include "util/async/Error.hpp"
24#include "util/async/impl/ErasedOperation.hpp"
44template <
typename RetType>
91 [[nodiscard]] std::expected<RetType, ExecutionError>
95 auto data = operation_.get();
97 return std::unexpected(std::move(
data).error());
99 if constexpr (std::is_void_v<RetType>) {
102 return std::any_cast<RetType>(std::move(
data).value());
105 }
catch (std::bad_any_cast
const& e) {
106 return std::unexpected{
ExecutionError(fmt::format(
"{}", std::this_thread::get_id()),
"Bad any cast")};
A type-erased operation that can be executed via AnyExecutionContext.
Definition AnyOperation.hpp:45
AnyOperation(impl::ErasedOperation &&operation)
Construct a new type-erased Operation object.
Definition AnyOperation.hpp:52
void abort() noexcept
Abort the operation.
Definition AnyOperation.hpp:81
void wait() noexcept
Wait for the operation to complete.
Definition AnyOperation.hpp:70
std::expected< RetType, ExecutionError > get()
Get the result of the operation.
Definition AnyOperation.hpp:92
Definition ErasedOperation.hpp:34
void abort()
Cancel if needed and request stop as soon as possible.
Definition ErasedOperation.hpp:69
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70
This namespace implements an async framework built on top of execution contexts.
Definition AnyExecutionContext.hpp:36
Error channel type for async operation of any ExecutionContext.
Definition Error.hpp:39