| 73 | } |
| 74 | |
| 75 | bool TaskScheduler::TaskQueue::execute_local_internal(Thread& thread, Task* parent) |
| 76 | { |
| 77 | /* stop if we run out of local tasks or reach the waiting task */ |
| 78 | if (right == 0 || &tasks[right-1] == parent) |
| 79 | return false; |
| 80 | |
| 81 | /* execute task */ |
| 82 | size_t oldRight = right; |
| 83 | tasks[right-1].run_internal(thread); |
| 84 | if (right != oldRight) { |
| 85 | THROW_RUNTIME_ERROR("you have to wait for spawned subtasks"); |
| 86 | } |
| 87 | |
| 88 | /* pop task and closure from stack */ |
| 89 | right--; |
| 90 | if (tasks[right].stackPtr != size_t(-1)) |
| 91 | stackPtr = tasks[right].stackPtr; |
| 92 | |
| 93 | /* also move left pointer */ |
| 94 | if (left >= right) left.store(right.load()); |
| 95 | |
| 96 | return right != 0; |
| 97 | } |
| 98 | |
| 99 | dll_export bool TaskScheduler::TaskQueue::execute_local(Thread& thread, Task* parent) { |
| 100 | return execute_local_internal(thread,parent); |
no test coverage detected