MCPcopy Create free account
hub / github.com/apache/arrow / MakeAutoStartingGenerator

Function MakeAutoStartingGenerator

cpp/src/arrow/util/async_generator.h:721–738  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

719/// This generator buffers one item (the first result) until it is delivered.
720template <typename T>
721AsyncGenerator<T> MakeAutoStartingGenerator(AsyncGenerator<T> generator) {
722 struct AutostartGenerator {
723 Future<T> operator()() {
724 if (first_future->is_valid()) {
725 Future<T> result = *first_future;
726 *first_future = Future<T>();
727 return result;
728 }
729 return source();
730 }
731
732 std::shared_ptr<Future<T>> first_future;
733 AsyncGenerator<T> source;
734 };
735
736 std::shared_ptr<Future<T>> first_future = std::make_shared<Future<T>>(generator());
737 return AutostartGenerator{std::move(first_future), std::move(generator)};
738}
739
740/// \see MakeReadaheadGenerator
741template <typename T>

Callers 2

TEST_PFunction · 0.85

Calls

no outgoing calls

Tested by 1

TEST_PFunction · 0.68