18 namespace onnxruntime {
22 : state_(count << 1), notified_(false), spin_(spin) {
23 assert(((count << 1) >> 1) == count);
29 assert((state_ >> 1) == 0);
34 unsigned int delta =
c << 1;
35 unsigned int v = state_.fetch_sub(delta, std::memory_order_acq_rel) - delta;
40 assert(((v + delta) & ~1) != 0);
43 std::unique_lock<OrtMutex> l(mu_);
51 while ((state_ >> 1) != 0) {
55 unsigned int v = state_.fetch_or(1, std::memory_order_acq_rel);
58 std::unique_lock<OrtMutex> l(mu_);
68 std::atomic<unsigned int> state_;
void notify_all() noexcept
void wait(std::unique_lock< OrtMutex > &lk)
void Notify(unsigned int c=1)
Barrier(unsigned int count, bool spin=false)