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

Method operator()

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

Source from the content-addressed store, hash-verified

217
218 struct Callback {
219 void operator()(const Result<T>& maybe_next) {
220 Future<V> sink;
221 bool end = !maybe_next.ok() || IsIterationEnd(*maybe_next);
222 bool should_purge = false;
223 bool should_trigger;
224 {
225 auto guard = state->mutex.Lock();
226 // A MappedCallback may have purged or be purging the queue;
227 // we shouldn't do anything here.
228 if (state->finished) return;
229 if (end) {
230 should_purge = !state->finished;
231 state->finished = true;
232 }
233 sink = state->waiting_jobs.front();
234 state->waiting_jobs.pop_front();
235 should_trigger = !end && !state->waiting_jobs.empty();
236 }
237 if (should_purge) {
238 state->Purge();
239 }
240 if (should_trigger) {
241 state->source().AddCallback(Callback{state});
242 }
243 if (maybe_next.ok()) {
244 const T& val = maybe_next.ValueUnsafe();
245 if (IsIterationEnd(val)) {
246 sink.MarkFinished(IterationTraits<V>::End());
247 } else {
248 Future<V> mapped_fut = state->map(val);
249 mapped_fut.AddCallback(MappedCallback{std::move(state), std::move(sink)});
250 }
251 } else {
252 sink.MarkFinished(maybe_next.status());
253 }
254 }
255
256 std::shared_ptr<State> state;
257 };

Callers

nothing calls this directly

Calls 12

IsIterationEndFunction · 0.85
sourceMethod · 0.80
ValueUnsafeMethod · 0.80
mapMethod · 0.80
EndFunction · 0.70
okMethod · 0.45
LockMethod · 0.45
emptyMethod · 0.45
PurgeMethod · 0.45
AddCallbackMethod · 0.45
MarkFinishedMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected