MCPcopy Create free account
hub / github.com/RenderKit/oidn / processQueue

Method processQueue

devices/cpu/cpu_engine.cpp:192–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190 }
191
192 void CPUEngine::processQueue()
193 {
194 for (; ;)
195 {
196 Task task;
197
198 // Wait until a task is available in the queue
199 {
200 std::unique_lock<std::mutex> lock(queueMutex);
201 queueCond.wait(lock, [&] { return !queue.empty() || queueShutdown; });
202 if (queue.empty() && queueShutdown)
203 return;
204 task = std::move(queue.front());
205 }
206
207 // Execute queued tasks in the arena until the queue gets empty
208 arena->execute([&]
209 {
210 for (; ;)
211 {
212 if (task.ct && task.ct->isCancelled())
213 device->setAsyncError(Error::Cancelled, "execution was cancelled");
214 else
215 task.func();
216
217 task = {};
218
219 {
220 std::lock_guard<std::mutex> lock(queueMutex);
221 queue.pop();
222 if (queue.empty())
223 break;
224 task = std::move(queue.front());
225 }
226 }
227
228 queueCond.notify_all();
229 });
230 }
231 }
232
233OIDN_NAMESPACE_END

Callers

nothing calls this directly

Calls 5

isCancelledMethod · 0.80
setAsyncErrorMethod · 0.80
waitMethod · 0.45
emptyMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected