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

Method Push

cpp/src/arrow/util/async_generator.h:875–895  ·  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

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

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