MCPcopy Create free account
hub / github.com/RichieSams/FiberTaskingLib / GetNextLoPriTask

Method GetNextLoPriTask

source/task_scheduler.cpp:581–605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

579}
580
581bool TaskScheduler::GetNextLoPriTask(TaskBundle *nextTask) {
582 unsigned const currentThreadIndex = GetCurrentThreadIndex();
583 ThreadLocalStorage &tls = m_tls[currentThreadIndex];
584
585 // Try to pop from our own queue
586 if (tls.LoPriTaskQueue.Pop(nextTask)) {
587 return true;
588 }
589
590 // Ours is empty, try to steal from the others'
591 const unsigned threadIndex = tls.LoPriLastSuccessfulSteal;
592 for (unsigned i = 0; i < m_numThreads; ++i) {
593 const unsigned threadIndexToStealFrom = (threadIndex + i) % m_numThreads;
594 if (threadIndexToStealFrom == currentThreadIndex) {
595 continue;
596 }
597 ThreadLocalStorage &otherTLS = m_tls[threadIndexToStealFrom];
598 if (otherTLS.LoPriTaskQueue.Steal(nextTask)) {
599 tls.LoPriLastSuccessfulSteal = threadIndexToStealFrom;
600 return true;
601 }
602 }
603
604 return false;
605}
606
607unsigned TaskScheduler::GetNextFreeFiberIndex() const {
608 for (unsigned j = 0;; ++j) {

Callers 1

FiberStartFuncMethod · 0.80

Calls 2

PopMethod · 0.80
StealMethod · 0.80

Tested by

no test coverage detected