lidavidm commented on a change in pull request #9995:
URL: https://github.com/apache/arrow/pull/9995#discussion_r611816347



##########
File path: cpp/src/arrow/util/async_generator.h
##########
@@ -1332,4 +1332,49 @@ Result<Iterator<T>> MakeReadaheadIterator(Iterator<T> 
it, int readahead_queue_si
   return MakeGeneratorIterator(std::move(owned_bg_generator));
 }
 
+/// \brief Make a generator that returns a single pre-generated future
+template <typename T>
+std::function<Future<T>()> MakeSingleFutureGenerator(Future<T> future) {
+  assert(future.is_valid());
+  struct Generator {
+    Future<T> future;
+
+    Future<T> operator()() {
+      if (future.is_valid()) {
+        return std::move(future);
+      } else {
+        return IterationEnd<T>();

Review comment:
       Right, in #9547 I added convenience constructors to enable 
`ARROW_ASSIGN_OR_RAISE` macros and the like to work but didn't intend for them 
to replace MakeFinished.
   
   That said I'm not too set on it and given we use the conveniences for 
Result, I'm not entirely opposed to using them for Future as well. Given we 
have a lot more async code now and will be adding a lot more in the future, if 
overall it's more convenient for people then we can go back and get rid of 
MakeFinished. We'd also need an implicit constructor for `Future<T>` from `T` 
in addition to the one from `Result<T>`.




-- 
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:
[email protected]


Reply via email to