43 std::reference_wrapper<ParentContextType> parentContext_;
44 typename ParentContextType::ContextHolderType::Strand context_;
48 static constexpr bool kIS_NOEXCEPT =
noexcept(ErrorHandlerType::wrap([](
auto&) {
throw 0; }));
50 using ContextHolderType =
typename ParentContextType::ContextHolderType::Strand;
51 using ExecutorType =
typename ContextHolderType::Executor;
52 using StopToken =
typename StopSourceType::Token;
54 typename ParentContextType::ContextHolderType::Timer;
56 BasicStrand(ParentContextType& parent,
auto&& strand)
57 : parentContext_{std::ref(parent)}, context_{std::forward<decltype(strand)>(strand)}
68 noexcept(kIS_NOEXCEPT)
70 return DispatcherType::dispatch(
72 impl::outcomeForHandler<StopSourceType>(fn),
73 ErrorHandlerType::wrap([
this, timeout, fn = std::forward<
decltype(fn)>(fn)](
74 auto& outcome,
auto& stopSource,
auto stopToken
76 [[maybe_unused]]
auto timeoutHandler = impl::getTimeoutHandleIfNeeded(
77 TimerContextProvider::getContext(parentContext_.get()), timeout, stopSource
80 using FnRetType = std::decay_t<decltype(fn(std::declval<StopToken>()))>;
81 if constexpr (std::is_void_v<FnRetType>) {
82 fn(std::move(stopToken));
85 outcome.setValue(fn(std::move(stopToken)));
95 std::forward<
decltype(fn)>(fn),
96 std::make_optional(std::chrono::duration_cast<std::chrono::milliseconds>(timeout))
103 return DispatcherType::dispatch(
105 impl::outcomeForHandler<StopSourceType>(fn),
106 ErrorHandlerType::wrap([fn = std::forward<
decltype(fn)>(fn)](
auto& outcome)
mutable {
107 using FnRetType = std::decay_t<
decltype(fn())>;
108 if constexpr (std::is_void_v<FnRetType>) {
112 outcome.setValue(fn());