6 #include <condition_variable>
11 eventcount() : waiters(0)
18 unsigned cmp = count.load(std::memory_order_relaxed);
24 unsigned cmp = count.fetch_add(0, std::memory_order_seq_cst);
30 unsigned cmp = count.fetch_or(0x80000000,
31 std::memory_order_seq_cst);
32 return cmp & 0x7FFFFFFF;
35 void wait(unsigned cmp)
37 unsigned ec = count.load(std::memory_order_seq_cst);
38 if (cmp == (ec & 0x7FFFFFFF))
41 ec = count.load(std::memory_order_seq_cst);
42 if (cmp == (ec & 0x7FFFFFFF))
52 std::atomic<unsigned> count;
53 rl::var<unsigned> waiters;
55 std::condition_variable cv;
57 void signal_impl(unsigned cmp)
62 while (false == count.compare_exchange_weak(cmp,
63 (cmp + 1) & 0x7FFFFFFF, std::memory_order_relaxed));
64 unsigned w = waiters($);