19 #include <condition_variable> 22 #include <unordered_map> 67 uint64_t current_mask = 0, new_mask;
69 while (current_mask == 0) {
70 new_mask =
static_cast<uint64_t
>(1) << shift++;
71 current_mask = !(collective_mask_ & new_mask) ? new_mask : 0;
72 if (shift > max_size) {
73 throw std::overflow_error(
"No more masks available");
76 collective_mask_ |= current_mask;
86 collective_mask_ &= ~mask;
93 return collective_mask_;
96 static constexpr
size_t max_size =
sizeof(uint64_t) * 8;
97 uint64_t collective_mask_ = 0;
104 std::cv_status waitForWork(
const std::chrono::microseconds &duration);
107 virtual bool hasWork() = 0;
122 void addStatusMonitor(std::shared_ptr<StatusMonitor> &status_monitor);
126 bool hasWork()
override;
128 std::atomic<uint64_t> mask_{};
void setStatusObserver(MultiStatusConditionMonitor *multi_status_cond)
void removeMask(uint64_t mask)
uint64_t getCollectiveMask() const
void setStatus(const Status &status)
MaskFactory mask_factory_
MultiStatusConditionMonitor * multi_status_cond_
MultiStatusConditionMonitor()
std::condition_variable work_condition_
std::unordered_map< StatusMonitor *, uint64_t > status_monitors_
virtual ~StatusMonitor()=default
friend MultiStatusConditionMonitor