| 249 | } |
| 250 | |
| 251 | void TaskScheduler::ThreadEndFunc(void *arg) { |
| 252 | TaskScheduler *taskScheduler = reinterpret_cast<TaskScheduler *>(arg); |
| 253 | |
| 254 | // Wait for all other threads to quit |
| 255 | taskScheduler->m_quitCount.fetch_add(1, std::memory_order_seq_cst); |
| 256 | while (taskScheduler->m_quitCount.load(std::memory_order_seq_cst) != taskScheduler->m_numThreads) { |
| 257 | SleepThread(50); |
| 258 | } |
| 259 | |
| 260 | // Jump to the thread fibers |
| 261 | unsigned threadIndex = taskScheduler->GetCurrentThreadIndex(); |
| 262 | |
| 263 | if (threadIndex == 0) { |
| 264 | // Special case for the main thread fiber |
| 265 | taskScheduler->m_quitFibers[threadIndex].SwitchToFiber(&taskScheduler->m_fibers[0]); |
| 266 | } else { |
| 267 | taskScheduler->m_quitFibers[threadIndex].SwitchToFiber(&taskScheduler->m_tls[threadIndex].ThreadFiber); |
| 268 | } |
| 269 | |
| 270 | // We should never get here |
| 271 | printf("Error: ThreadEndFunc should never return"); |
| 272 | } |
| 273 | |
| 274 | TaskScheduler::TaskScheduler() { |
| 275 | FTL_VALGRIND_HG_DISABLE_CHECKING(&m_initialized, sizeof(m_initialized)); |
nothing calls this directly
no test coverage detected