MCPcopy Create free account
hub / github.com/apache/arrow / operator()

Method operator()

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

Source from the content-addressed store, hash-verified

554 : state_(std::make_shared<State>(std::move(source_generator), max_readahead)) {}
555
556 Future<T> operator()() {
557 if (state_->first_) {
558 // Lazy generator, need to wait for the first ask to prime the pump
559 state_->first_ = false;
560 auto next = state_->source_();
561 return next.Then(Callback{state_}, ErrCallback{state_});
562 }
563
564 // This generator is not async-reentrant. We won't be called until the last
565 // future finished so we know there is something in the queue
566 auto finished = state_->finished_.load();
567 if (finished && state_->readahead_queue_.IsEmpty()) {
568 return AsyncGeneratorEnd<T>();
569 }
570
571 std::shared_ptr<Future<T>> next;
572 if (!state_->readahead_queue_.Read(next)) {
573 return Status::UnknownError("Could not read from readahead_queue");
574 }
575
576 auto last_available = state_->spaces_available_.fetch_add(1);
577 if (last_available == 0 && !finished) {
578 // Reader idled out, we need to restart it
579 ARROW_RETURN_NOT_OK(state_->Pump(state_));
580 }
581 return *next;
582 }
583
584 private:
585 struct State {

Callers

nothing calls this directly

Calls 5

UnknownErrorFunction · 0.85
ThenMethod · 0.80
loadMethod · 0.45
ReadMethod · 0.45
PumpMethod · 0.45

Tested by

no test coverage detected