Add function to detach from a thread

This commit is contained in:
baldurk
2019-02-14 16:54:40 +00:00
parent 34a97482dd
commit fb9aac95d1
3 changed files with 12 additions and 0 deletions
+1
View File
@@ -147,6 +147,7 @@ typedef uint64_t ThreadHandle;
ThreadHandle CreateThread(std::function<void()> entryFunc);
uint64_t GetCurrentID();
void JoinThread(ThreadHandle handle);
void DetachThread(ThreadHandle handle);
void CloseThread(ThreadHandle handle);
void Sleep(uint32_t milliseconds);
+4
View File
@@ -282,6 +282,10 @@ void JoinThread(ThreadHandle handle)
{
pthread_join((pthread_t)handle, NULL);
}
void DetachThread(ThreadHandle handle)
{
pthread_detach((pthread_t)handle);
}
void CloseThread(ThreadHandle handle)
{
}
+7
View File
@@ -273,6 +273,13 @@ void JoinThread(ThreadHandle handle)
WaitForSingleObject((HANDLE)handle, INFINITE);
}
void DetachThread(ThreadHandle handle)
{
if(handle == 0)
return;
CloseHandle((HANDLE)handle);
}
void CloseThread(ThreadHandle handle)
{
if(handle == 0)