MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / stealWork

Method stealWork

modules/core/task/src/task2.cpp:212–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210 }
211
212 int stealWork(int rand)
213 {
214 Task stolen(nullptr);
215 auto numThreads = scheduler->config.numThreads;
216 if(numThreads > 1)
217 {
218 SkrZoneScopedN("Worker::StealWork");
219 // Try to steal from other workers
220 while(rand == id)
221 rand = rnd() % numThreads;
222 auto& worker = *(Worker*)scheduler->workers[rand];
223 if(worker.steal(stolen))
224 {
225 stolen();
226 return rand;
227 }
228 else
229 {
230 return id;
231 }
232 }
233 return id;
234 }
235
236 void spinForWork()
237 {

Callers 1

syncMethod · 0.80

Calls 1

stealMethod · 0.45

Tested by

no test coverage detected