10 #ifndef EIGEN_CXX11_THREADPOOL_EVENTCOUNT_H_ 11 #define EIGEN_CXX11_THREADPOOL_EVENTCOUNT_H_ 69 std::atomic_thread_fence(std::memory_order_seq_cst);
85 state =
state_.load(std::memory_order_seq_cst);
89 if (
int64_t((state & kEpochMask) - epoch) > 0)
return;
95 w->next.store(
nullptr, std::memory_order_relaxed);
97 w->next.store(&
waiters_[state & kStackMask], std::memory_order_relaxed);
98 if (
state_.compare_exchange_weak(state, newstate,
99 std::memory_order_release))
116 state =
state_.load(std::memory_order_relaxed);
120 if (
int64_t((state & kEpochMask) - epoch) > 0)
return;
124 std::memory_order_relaxed))
132 std::atomic_thread_fence(std::memory_order_seq_cst);
143 }
else if (waiters) {
149 Waiter* wnext = w->next.load(std::memory_order_relaxed);
151 if (wnext !=
nullptr) next = wnext - &
waiters_[0];
158 if (
state_.compare_exchange_weak(state, newstate,
159 std::memory_order_acquire)) {
160 if (!all && waiters)
return;
161 if ((state & kStackMask) ==
kStackMask)
return;
163 if (!all) w->next.store(
nullptr, std::memory_order_relaxed);
205 std::unique_lock<std::mutex> lock(w->
mu);
215 next =
w->next.load(std::memory_order_relaxed);
218 std::unique_lock<std::mutex> lock(
w->mu);
233 #endif // EIGEN_CXX11_THREADPOOL_EVENTCOUNT_H_
std::condition_variable cv
EventCount(MaxSizeVector< Waiter > &waiters)
static const uint64_t kEpochMask
Namespace containing all symbols from the Eigen library.
static const uint64_t kEpochShift
static const uint64_t kWaiterMask
void operator=(const EventCount &)=delete
MaxSizeVector< Waiter > & waiters_
static const uint64_t kStackMask
EIGEN_ALIGN_TO_BOUNDARY(128) std std::mutex mu
static const uint64_t kWaiterBits
std::atomic< uint64_t > state_
void Unpark(Waiter *waiters)
unsigned __int64 uint64_t
#define EIGEN_THREAD_YIELD()
void CancelWait(Waiter *w)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t size() const
static const uint64_t kWaiterShift
static const uint64_t kStackBits
static const uint64_t kEpochBits
static const uint64_t kWaiterInc
static const uint64_t kEpochInc
void CommitWait(Waiter *w)