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

Method Close

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

\brief Tell the consumer we have finished producing It is allowed to call this and later call Push() again ("early close"). In this case, calls to Push() after the queue is closed are silently ignored. This can help implementing non-trivial cancellation cases. True is returned on success, false if the generator is already closed or destroyed.

Source from the content-addressed store, hash-verified

903 /// True is returned on success, false if the generator is already closed
904 /// or destroyed.
905 bool Close() {
906 auto state = weak_state_.lock();
907 if (!state) {
908 // Generator was destroyed
909 return false;
910 }
911 auto lock = state->mutex.Lock();
912 if (state->finished) {
913 // Already closed
914 return false;
915 }
916 state->finished = true;
917 if (state->consumer_fut.has_value()) {
918 auto fut = std::move(state->consumer_fut.value());
919 state->consumer_fut.reset();
920 lock.Unlock(); // unlock before potentially invoking a callback
921 fut.MarkFinished(IterationTraits<T>::End());
922 }
923 return true;
924 }
925
926 /// Return whether the generator was closed or destroyed.
927 bool is_closed() const {

Callers

nothing calls this directly

Calls 6

EndFunction · 0.70
LockMethod · 0.45
valueMethod · 0.45
resetMethod · 0.45
UnlockMethod · 0.45
MarkFinishedMethod · 0.45

Tested by

no test coverage detected