| 132 | } |
| 133 | |
| 134 | bool Threads::init(u8 min, u8 max) |
| 135 | { |
| 136 | minWorkers = min; |
| 137 | maxWorkers = max; |
| 138 | auto lockedThreads = threads.lock(); |
| 139 | lockedThreads->second.emplace_back(); |
| 140 | if (R_FAILED(svcCreateEvent(&lockedThreads->second[0], RESET_ONESHOT))) { |
| 141 | return false; |
| 142 | } |
| 143 | lockedThreads->second.emplace_back(); |
| 144 | if (R_FAILED(svcCreateEvent(&lockedThreads->second[1], RESET_ONESHOT))) { |
| 145 | return false; |
| 146 | } |
| 147 | s32 prio = 0; |
| 148 | if (R_FAILED(svcGetThreadPriority(&prio, CUR_THREAD_HANDLE))) { |
| 149 | return false; |
| 150 | } |
| 151 | reaperThread = threadCreate(reapThread, nullptr, 0x400, prio - 3, -2, false); |
| 152 | if (!reaperThread) { |
| 153 | return false; |
| 154 | } |
| 155 | |
| 156 | LightSemaphore_Init(&moreTasks, 0, 10000); |
| 157 | for (int i = 0; i < minWorkers; i++) { |
| 158 | if (!Threads::create(WORKER_STACK, taskWorkerThread)) { |
| 159 | return false; |
| 160 | } |
| 161 | } |
| 162 | return true; |
| 163 | } |
| 164 | |
| 165 | bool Threads::create(void (*entrypoint)(void*), void* arg, std::optional<size_t> stackSize) |
| 166 | { |
nothing calls this directly
no test coverage detected