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

Method create

switch/source/thread.cpp:51–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51bool Threads::create(std::optional<size_t> stackSize, void (*entrypoint)(void))
52{
53 // Reap the previous worker before reusing the slot. The sole caller
54 // (ScriptRunner) only creates a new thread once the previous run's result
55 // was collected, so this wait is at most the tail of a returning thread.
56 join();
57
58 // Stack size must be page-aligned or threadCreate fails with
59 // LibnxError_BadInput (see the network thread in main.cpp).
60 size_t stack = stackSize.value_or(0x8000);
61 stack = (stack + 0xFFF) & ~(size_t)0xFFF;
62
63 gEntry = entrypoint;
64 Result rc = threadCreate(&gThread, thunk, nullptr, nullptr, stack, 0x2C, -2);
65 if (R_FAILED(rc)) {
66 Logging::error("[thread] threadCreate failed with result 0x{:08X}", rc);
67 return false;
68 }
69 if (R_FAILED(rc = threadStart(&gThread))) {
70 Logging::error("[thread] threadStart failed with result 0x{:08X}", rc);
71 threadClose(&gThread);
72 return false;
73 }
74 gThreadLive = true;
75 return true;
76}

Callers 6

oneShotCommandsFunction · 0.45
flushTexUploadsFunction · 0.45
createFramebuffersFunction · 0.45
InitMethod · 0.45
flushGlyphUploadsFunction · 0.45
allocateMethod · 0.45

Calls 1

errorFunction · 0.85

Tested by

no test coverage detected