mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-07-02 15:56:02 +00:00
Fix thread detachment on Vita
This commit is contained in:
parent
9686f6942f
commit
59f7f62b62
@ -88,7 +88,13 @@ void* ThreadProc(void* context) {
|
|||||||
ctx->entry(ctx->context);
|
ctx->entry(ctx->context);
|
||||||
|
|
||||||
#if defined(__vita__)
|
#if defined(__vita__)
|
||||||
ctx->thread->alive = false;
|
if (ctx->thread->detached) {
|
||||||
|
free(ctx);
|
||||||
|
sceKernelExitDeleteThread(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
free(ctx);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
free(ctx);
|
free(ctx);
|
||||||
#endif
|
#endif
|
||||||
@ -192,6 +198,7 @@ void PltJoinThread(PLT_THREAD* thread) {
|
|||||||
WaitForSingleObjectEx(thread->handle, INFINITE, FALSE);
|
WaitForSingleObjectEx(thread->handle, INFINITE, FALSE);
|
||||||
CloseHandle(thread->handle);
|
CloseHandle(thread->handle);
|
||||||
#elif defined(__vita__)
|
#elif defined(__vita__)
|
||||||
|
LC_ASSERT(!thread->detached);
|
||||||
sceKernelWaitThreadEnd(thread->handle, NULL, NULL);
|
sceKernelWaitThreadEnd(thread->handle, NULL, NULL);
|
||||||
sceKernelDeleteThread(thread->handle);
|
sceKernelDeleteThread(thread->handle);
|
||||||
#elif defined(__WIIU__)
|
#elif defined(__WIIU__)
|
||||||
@ -213,7 +220,8 @@ void PltDetachThread(PLT_THREAD* thread) {
|
|||||||
// "Closing a thread handle does not terminate the associated thread or remove the thread object."
|
// "Closing a thread handle does not terminate the associated thread or remove the thread object."
|
||||||
CloseHandle(thread->handle);
|
CloseHandle(thread->handle);
|
||||||
#elif defined(__vita__)
|
#elif defined(__vita__)
|
||||||
sceKernelDeleteThread(thread->handle);
|
LC_ASSERT(!thread->detached);
|
||||||
|
thread->detached = true;
|
||||||
#elif defined(__WIIU__)
|
#elif defined(__WIIU__)
|
||||||
OSDetachThread(&thread->thread);
|
OSDetachThread(&thread->thread);
|
||||||
#elif defined(__3DS__)
|
#elif defined(__3DS__)
|
||||||
@ -261,7 +269,7 @@ int PltCreateThread(const char* name, ThreadEntry entry, void* context, PLT_THRE
|
|||||||
}
|
}
|
||||||
#elif defined(__vita__)
|
#elif defined(__vita__)
|
||||||
{
|
{
|
||||||
thread->alive = true;
|
thread->detached = false;
|
||||||
thread->context = ctx;
|
thread->context = ctx;
|
||||||
ctx->thread = thread;
|
ctx->thread = thread;
|
||||||
thread->handle = sceKernelCreateThread(name, ThreadProc, 0, 0x40000, 0, 0, NULL);
|
thread->handle = sceKernelCreateThread(name, ThreadProc, 0, 0x40000, 0, 0, NULL);
|
||||||
|
@ -19,7 +19,7 @@ typedef struct _PLT_THREAD {
|
|||||||
int handle;
|
int handle;
|
||||||
int cancelled;
|
int cancelled;
|
||||||
void *context;
|
void *context;
|
||||||
bool alive;
|
bool detached;
|
||||||
} PLT_THREAD;
|
} PLT_THREAD;
|
||||||
#elif defined(__WIIU__)
|
#elif defined(__WIIU__)
|
||||||
typedef OSFastMutex PLT_MUTEX;
|
typedef OSFastMutex PLT_MUTEX;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user