7 #include <condition_variable>
12 eventcount() : waiters(0)
19 unsigned cmp = count.load(std::memory_order_relaxed);
25 unsigned cmp = count.fetch_add(0, std::memory_order_seq_cst);
31 unsigned cmp = count.fetch_or(0x80000000,
32 std::memory_order_seq_cst);
33 return cmp & 0x7FFFFFFF;
36 void wait(unsigned cmp)
38 unsigned ec = count.load(std::memory_order_seq_cst);
39 if (cmp == (ec & 0x7FFFFFFF))
42 ec = count.load(std::memory_order_seq_cst);
43 if (cmp == (ec & 0x7FFFFFFF))
53 std::atomic<unsigned> count;
54 rl::var<unsigned> waiters;
56 std::condition_variable cv;
58 void signal_impl(unsigned cmp)
63 while (false == count.compare_exchange_weak(cmp,
64 (cmp + 1) & 0x7FFFFFFF, std::memory_order_relaxed));
65 unsigned w = waiters($);