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

Method Close

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

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