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

Method RegisterHandlers

cpp/src/arrow/util/cancel.cc:138–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136 }
137
138 Status RegisterHandlers(const std::vector<int>& signals) {
139 std::lock_guard<std::mutex> lock(mutex_);
140 if (!saved_handlers_.empty()) {
141 return Status::Invalid("Signal handlers already registered");
142 }
143 if (!self_pipe_) {
144 // Make sure the self-pipe is initialized
145 // (NOTE: avoid std::atomic_is_lock_free() which may require libatomic)
146#if ATOMIC_POINTER_LOCK_FREE != 2
147 return Status::NotImplemented(
148 "Cannot setup signal StopSource because atomic pointers are not "
149 "lock-free on this platform");
150#else
151 ARROW_ASSIGN_OR_RAISE(self_pipe_, SelfPipe::Make(/*signal_safe=*/true));
152#endif
153 }
154 if (!signal_receiving_thread_) {
155 // Spawn thread for receiving signals
156 SpawnSignalReceivingThread();
157 }
158 self_pipe_ptr_.store(self_pipe_.get());
159 for (int signum : signals) {
160 ARROW_ASSIGN_OR_RAISE(auto handler,
161 SetSignalHandler(signum, SignalHandler{&HandleSignal}));
162 saved_handlers_.push_back({signum, handler});
163 }
164 return Status::OK();
165 }
166
167 void UnregisterHandlers() {
168 std::lock_guard<std::mutex> lock(mutex_);

Callers 1

Calls 9

storeMethod · 0.80
push_backMethod · 0.80
MakeFunction · 0.70
InvalidFunction · 0.50
NotImplementedFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
OKFunction · 0.50
emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected