| 119 | } |
| 120 | |
| 121 | std::size_t orbis::EventFlag::notify(NotifyType type, std::uint64_t bits) { |
| 122 | rx::writer_lock lock(queueMtx); |
| 123 | auto patValue = value.load(std::memory_order::relaxed); |
| 124 | |
| 125 | if (type == NotifyType::Destroy) { |
| 126 | isDeleted = true; |
| 127 | } else if (type == NotifyType::Set) { |
| 128 | patValue |= bits; |
| 129 | } |
| 130 | |
| 131 | auto testThread = [&](WaitingThread *thread) { |
| 132 | if (type == NotifyType::Set && !thread->test(patValue)) { |
| 133 | return false; |
| 134 | } |
| 135 | |
| 136 | auto resultValue = thread->applyClear(patValue); |
| 137 | thread->thread->evfResultPattern = patValue; |
| 138 | thread->thread->evfIsCancelled = type == NotifyType::Cancel; |
| 139 | patValue = resultValue; |
| 140 | |
| 141 | // TODO: update thread state |
| 142 | // release wait on waiter thread |
| 143 | thread->thread->sync_cv.notify_all(queueMtx); |
| 144 | return true; |
| 145 | }; |
| 146 | |
| 147 | std::size_t result = std::erase_if( |
| 148 | waitingThreads, [&](auto &thread) { return testThread(&thread); }); |
| 149 | |
| 150 | if (type == NotifyType::Cancel) { |
| 151 | value.store(bits, std::memory_order::relaxed); |
| 152 | } else { |
| 153 | value.store(patValue, std::memory_order::relaxed); |
| 154 | } |
| 155 | return result; |
| 156 | } |
nothing calls this directly
no test coverage detected