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

Function MakeAutoStartingGenerator

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

Source from the content-addressed store, hash-verified

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

Callers 2

TEST_PFunction · 0.85

Calls

no outgoing calls

Tested by 1

TEST_PFunction · 0.68