3#include "utils/macros.h"
6#include <condition_variable>
36 using counter_type = uint32_t;
37 static constexpr counter_type not_waiting_magic = 0x10000;
38 static constexpr counter_type count_mask = not_waiting_magic - 1;
39 std::mutex m_counter_is_zero_mutex;
40 std::condition_variable m_counter_is_zero;
41 std::atomic<counter_type> m_counter{not_waiting_magic};
45 [[gnu::always_inline]]
bool is_waiting()
const
47 return !(m_counter & not_waiting_magic);
58 Dout(dc::warning,
"TaskCounterGate::increment called after wait [" <<
this <<
"]");
59 throw std::exception();
61 m_counter.fetch_add(1, std::memory_order::relaxed);
67 counter_type previous_value = m_counter.fetch_sub(1, std::memory_order::relaxed);
69 ASSERT(previous_value != 0);
70 if (AI_UNLIKELY(previous_value == 1))
Definition: TaskCounterGate.h:35
Tasks defined by the library project are put into this namespace.
Definition: AIStatefulTask.h:857