westonpace commented on a change in pull request #10205: URL: https://github.com/apache/arrow/pull/10205#discussion_r631925048
########## File path: cpp/src/arrow/util/future.h ########## @@ -78,28 +110,32 @@ struct ContinueFuture { template <typename ContinueFunc, typename... Args, typename ContinueResult = result_of_t<ContinueFunc && (Args && ...)>, typename NextFuture = ForReturn<ContinueResult>> - typename std::enable_if<!std::is_void<ContinueResult>::value && - !is_future<ContinueResult>::value>::type + typename std::enable_if< + !std::is_void<ContinueResult>::value && !is_future<ContinueResult>::value && + (!NextFuture::is_empty || std::is_same<ContinueResult, Status>::value)>::type operator()(NextFuture next, ContinueFunc&& f, Args&&... a) const { next.MarkFinished(std::forward<ContinueFunc>(f)(std::forward<Args>(a)...)); } + template <typename ContinueFunc, typename... Args, + typename ContinueResult = result_of_t<ContinueFunc && (Args && ...)>, + typename NextFuture = ForReturn<ContinueResult>> + typename std::enable_if<!std::is_void<ContinueResult>::value && + !is_future<ContinueResult>::value && NextFuture::is_empty && + !std::is_same<ContinueResult, Status>::value>::type + operator()(NextFuture next, ContinueFunc&& f, Args&&... a) const { + next.MarkFinished(std::forward<ContinueFunc>(f)(std::forward<Args>(a)...).status()); Review comment: That could maybe collapse two of these cases. Although that middle overload is a partial function specialization which I don't think is allowed. I'm not sure it ends up being any simpler. I think this was more necessary with the two classes approach. ########## File path: cpp/src/arrow/util/future.h ########## @@ -691,34 +876,41 @@ struct Continue { } }; -template <typename T = detail::Empty> +template <typename T = internal::Empty> util::optional<T> Break(T break_value = {}) { return util::optional<T>{std::move(break_value)}; } -template <typename T = detail::Empty> +template <typename T = internal::Empty> using ControlFlow = util::optional<T>; +template <typename T> +void ForwardControlResult(const Result<ControlFlow<T>>& result, Future<T> sink) { + sink.MarkFinished(**result); +} +template <> +inline void ForwardControlResult(const Result<ControlFlow<>>& result, Future<> sink) { + sink.MarkFinished(); Review comment: This has gone away. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org