MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / init

Method init

3ds/source/thread.cpp:134–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134bool 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
165bool Threads::create(void (*entrypoint)(void*), void* arg, std::optional<size_t> stackSize)
166{

Callers

nothing calls this directly

Calls 3

emplace_backMethod · 0.80
createFunction · 0.50
lockMethod · 0.45

Tested by

no test coverage detected