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

Method Pump

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

Source from the content-addressed store, hash-verified

593 readahead_queue_(max_readahead + 1) {}
594
595 Status Pump(const std::shared_ptr<State>& self) {
596 // Can't do readahead_queue.write(source().Then(...)) because then the
597 // callback might run immediately and add itself to the queue before this gets added
598 // to the queue messing up the order.
599 auto next_slot = std::make_shared<Future<T>>();
600 auto written = readahead_queue_.Write(next_slot);
601 if (!written) {
602 return Status::UnknownError("Could not write to readahead_queue");
603 }
604 // If this Pump is being called from a callback it is possible for the source to
605 // poll and read from the queue between the Write and this spot where we fill the
606 // value in. However, it is not possible for the future to read this value we are
607 // writing. That is because this callback (the callback for future X) must be
608 // finished before future X is marked complete and this source is not pulled
609 // reentrantly so it will not poll for future X+1 until this callback has completed.
610 *next_slot = source_().Then(Callback{self}, ErrCallback{self});
611 return Status::OK();
612 }
613
614 // Only accessed by the consumer end
615 bool first_;

Callers 2

operator()Method · 0.45
operator()Method · 0.45

Calls 4

UnknownErrorFunction · 0.85
ThenMethod · 0.80
OKFunction · 0.50
WriteMethod · 0.45

Tested by

no test coverage detected