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

Method Push

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

\brief Push a value on the queue True is returned if the value was pushed, false if the generator is already closed or destroyed. If the latter, it is recommended to stop producing any further values.

Source from the content-addressed store, hash-verified

872 /// already closed or destroyed. If the latter, it is recommended to stop
873 /// producing any further values.
874 bool Push(Result<T> result) {
875 auto state = weak_state_.lock();
876 if (!state) {
877 // Generator was destroyed
878 return false;
879 }
880 auto lock = state->mutex.Lock();
881 if (state->finished) {
882 // Closed early
883 return false;
884 }
885 if (state->consumer_fut.has_value()) {
886 auto fut = std::move(state->consumer_fut.value());
887 state->consumer_fut.reset();
888 lock.Unlock(); // unlock before potentially invoking a callback
889 fut.MarkFinished(std::move(result));
890 } else {
891 state->result_q.push_back(std::move(result));
892 }
893 return true;
894 }
895
896 /// \brief Tell the consumer we have finished producing
897 ///

Callers

nothing calls this directly

Calls 6

push_backMethod · 0.80
LockMethod · 0.45
valueMethod · 0.45
resetMethod · 0.45
UnlockMethod · 0.45
MarkFinishedMethod · 0.45

Tested by

no test coverage detected