Add threadDetach function

This commit is contained in:
Fenrir 2017-02-24 01:09:57 -07:00
parent 492fffd445
commit ce743f1b04
2 changed files with 19 additions and 0 deletions

View File

@ -65,6 +65,12 @@ void threadFree(Thread thread);
*/
Result threadJoin(Thread thread, u64 timeout_ns);
/**
* @brief Changes a thread's status from attached to detached.
* @param thread libctru thread handle
*/
void threadDetach(Thread thread);
/**
* @brief Retrieves the libctru thread handle of the current thread.
* @return libctru thread handle of the current thread, or NULL for the main thread

View File

@ -107,6 +107,19 @@ Result threadJoin(Thread thread, u64 timeout_ns)
return svcWaitSynchronization(thread->handle, timeout_ns);
}
void threadDetach(Thread thread)
{
if (!thread || thread->detached)
return;
if (thread->finished)
{
threadFree(thread);
return;
}
thread->detached = true;
return;
}
Thread threadGetCurrent(void)
{
ThreadVars* tv = getThreadVars();