mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-27 17:02:55 -04:00
Cleanly shut down JKRDecomp thread
Properly join the thread to ensure it's shut down before we try to exit. Fixes #268
This commit is contained in:
@@ -20,6 +20,15 @@ JKRDecomp* JKRDecomp::create(s32 priority) {
|
||||
return sDecompObject;
|
||||
}
|
||||
|
||||
#if TARGET_PC
|
||||
void JKRDecomp::destroy() {
|
||||
if (sDecompObject) {
|
||||
OSSendMessage(&sMessageQueue, nullptr, OS_MESSAGE_NOBLOCK);
|
||||
OSJoinThread(sDecompObject->getThreadRecord(), nullptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
OSMessage JKRDecomp::sMessageBuffer[8] = {0};
|
||||
|
||||
OSMessageQueue JKRDecomp::sMessageQueue = {0};
|
||||
@@ -34,15 +43,15 @@ void* JKRDecomp::run() {
|
||||
OSInitMessageQueue(&sMessageQueue, sMessageBuffer, 8);
|
||||
for (;;) {
|
||||
OSMessage message;
|
||||
#ifdef TARGET_PC
|
||||
if (!OSReceiveMessage(&sMessageQueue, &message, OS_MESSAGE_BLOCK)) {
|
||||
break;
|
||||
}
|
||||
#else
|
||||
OSReceiveMessage(&sMessageQueue, &message, OS_MESSAGE_BLOCK);
|
||||
#endif
|
||||
|
||||
JKRDecompCommand* command = (JKRDecompCommand*)message;
|
||||
#if TARGET_PC
|
||||
if (!command) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
decode(command->mSrcBuffer, command->mDstBuffer, command->mSrcLength, command->mDstLength);
|
||||
|
||||
if (command->field_0x20 != 0) {
|
||||
|
||||
Reference in New Issue
Block a user