MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / notify

Method notify

kernel/orbis/src/evf.cpp:121–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121std::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}

Callers

nothing calls this directly

Calls 5

applyClearMethod · 0.80
loadMethod · 0.45
testMethod · 0.45
notify_allMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected