4 //#include <unrelacy.h>
7 #include <condition_variable>
12 eventcount() : waiters(0)
19 unsigned cmp = count.load(std::memory_order_relaxed);
25 // We might be able to use release here because it basically only needs
26 // to synchronize with the get()
27 unsigned cmp = count.fetch_add(0, std::memory_order_seq_cst);
33 unsigned cmp = count.fetch_or(0x80000000,
34 std::memory_order_seq_cst);
35 return cmp & 0x7FFFFFFF;
38 void wait(unsigned cmp)
40 unsigned ec = count.load(std::memory_order_seq_cst);
41 if (cmp == (ec & 0x7FFFFFFF))
44 ec = count.load(std::memory_order_seq_cst);
45 if (cmp == (ec & 0x7FFFFFFF))
55 std::atomic<unsigned> count;
56 rl::var<unsigned> waiters;
58 std::condition_variable cv;
60 void signal_impl(unsigned cmp)
65 while (false == count.compare_exchange_weak(cmp,
66 (cmp + 1) & 0x7FFFFFFF, std::memory_order_relaxed));
67 unsigned w = waiters($);