westonpace commented on a change in pull request #9533: URL: https://github.com/apache/arrow/pull/9533#discussion_r581463408
########## File path: cpp/src/arrow/util/async_generator.h ########## @@ -177,6 +179,90 @@ class TransformingGenerator { std::shared_ptr<TransformingGeneratorState> state_; }; +template <typename T> +class SerialReadaheadGenerator { + public: + SerialReadaheadGenerator(AsyncGenerator<T> source_generator, int max_readahead) + : state_(std::make_shared<State>(std::move(source_generator), max_readahead)) {} + + Future<T> operator()() { + if (state_->first) { + // Lazy generator, need to wait for the first ask to prime the pump + state_->first = false; + auto next = state_->source(); + return next.Then(Callback{state_}); + } else { Review comment: Done ---------------------------------------------------------------- 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