MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / CancelWait

Method CancelWait

include/Eigen/src/ThreadPool/EventCount.h:110–123  ·  view source on GitHub ↗

CancelWait cancels effects of the previous Prewait call.

Source from the content-addressed store, hash-verified

108
109 // CancelWait cancels effects of the previous Prewait call.
110 void CancelWait() {
111 uint64_t state = state_.load(std::memory_order_relaxed);
112 for (;;) {
113 CheckState(state, true);
114 uint64_t newstate = state - kWaiterInc;
115 // We don't know if the thread was also notified or not,
116 // so we should not consume a signal unconditionally.
117 // Only if number of waiters is equal to number of signals,
118 // we know that the thread was notified and we must take away the signal.
119 if (((state & kWaiterMask) >> kWaiterShift) == ((state & kSignalMask) >> kSignalShift)) newstate -= kSignalInc;
120 CheckState(newstate);
121 if (state_.compare_exchange_weak(state, newstate, std::memory_order_acq_rel)) return;
122 }
123 }
124
125 // Notify wakes one or all waiting threads.
126 // Must be called after changing the associated wait predicate.

Callers 1

WaitForWorkMethod · 0.80

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected