MCPcopy Create free account
hub / github.com/TinyMPC/TinyMPC / CancelWait

Method CancelWait

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

CancelWait cancels effects of the previous Prewait call.

Source from the content-addressed store, hash-verified

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