MCPcopy Create free account
hub / github.com/alibaba/async_simple / clear

Method clear

async_simple/Signal.h:239–260  ·  view source on GitHub ↗

Clear the signal handler. If return false, it indicates that the signal handler has been executed or handler is empty

Source from the content-addressed store, hash-verified

237 // Clear the signal handler. If return false, it indicates
238 // that the signal handler has been executed or handler is empty
239 bool clear(SignalType type) {
240 logicAssert(std::popcount(static_cast<uint64_t>(type)) == 1,
241 "It's not allow to emplace for multiple signals");
242 auto oldHandlerPtr = loadHandler<false>(type);
243 if (oldHandlerPtr == nullptr) {
244 return false;
245 }
246 auto oldHandler = oldHandlerPtr->load(std::memory_order_acquire);
247 if (oldHandler ==
248 &detail::SignalSlotSharedState::HandlerManager::emittedTag ||
249 oldHandler == nullptr) {
250 return false;
251 }
252 if (!oldHandlerPtr->compare_exchange_strong(
253 oldHandler, nullptr, std::memory_order_release)) {
254 assert(oldHandler ==
255 &detail::SignalSlotSharedState::HandlerManager::emittedTag);
256 return false;
257 }
258 delete oldHandler;
259 return true;
260 }
261
262 class FilterGuard {
263 friend class Slot;

Callers 10

package_idMethod · 0.45
checkHasCanceledMethod · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
getCurrentCpusFunction · 0.45
Mutex_chainFunction · 0.45

Calls 1

logicAssertFunction · 0.85

Tested by 3

TEST_FFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36