|
|
|
@ -54,9 +54,9 @@ struct LoopTraits<absl::StatusOr<LoopCtl<T>>> { |
|
|
|
|
using Result = absl::StatusOr<T>; |
|
|
|
|
static LoopCtl<Result> ToLoopCtl(absl::StatusOr<LoopCtl<T>> value) { |
|
|
|
|
if (!value.ok()) return value.status(); |
|
|
|
|
const auto& inner = *value; |
|
|
|
|
auto& inner = *value; |
|
|
|
|
if (absl::holds_alternative<Continue>(inner)) return Continue{}; |
|
|
|
|
return absl::get<T>(inner); |
|
|
|
|
return absl::get<T>(std::move(inner)); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -104,14 +104,14 @@ class Loop { |
|
|
|
|
if (auto* p = promise_result.value_if_ready()) { |
|
|
|
|
// - then if it's Continue, destroy the promise and recreate a new one
|
|
|
|
|
// from our factory.
|
|
|
|
|
auto lc = LoopTraits<PromiseResult>::ToLoopCtl(*p); |
|
|
|
|
auto lc = LoopTraits<PromiseResult>::ToLoopCtl(std::move(*p)); |
|
|
|
|
if (absl::holds_alternative<Continue>(lc)) { |
|
|
|
|
Destruct(&promise_); |
|
|
|
|
Construct(&promise_, factory_.Make()); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
// - otherwise there's our result... return it out.
|
|
|
|
|
return absl::get<Result>(lc); |
|
|
|
|
return absl::get<Result>(std::move(lc)); |
|
|
|
|
} else { |
|
|
|
|
// Otherwise the inner promise was pending, so we are pending.
|
|
|
|
|
return Pending(); |
|
|
|
|