From 7b5887b271bb29986bbc83cbe505787876259767 Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Thu, 28 Nov 2013 22:24:13 -0500 Subject: [PATCH] WinRT: implemented SDL_DetachThread() for WinRT --- src/thread/stdcpp/SDL_systhread.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/thread/stdcpp/SDL_systhread.cpp b/src/thread/stdcpp/SDL_systhread.cpp index 02fcf76aa4624..6e043b4171534 100644 --- a/src/thread/stdcpp/SDL_systhread.cpp +++ b/src/thread/stdcpp/SDL_systhread.cpp @@ -130,6 +130,26 @@ SDL_SYS_WaitThread(SDL_Thread * thread) } } +extern "C" +void +SDL_SYS_DetachThread(SDL_Thread * thread) +{ + if ( ! thread) { + return; + } + + try { + std::thread * cpp_thread = (std::thread *) thread->handle; + if (cpp_thread->joinable()) { + cpp_thread->detach(); + } + } catch (std::system_error &) { + // An error occurred when detaching the thread. SDL_DetachThread does not, + // however, seem to provide a means to report errors to its callers + // though! + } +} + extern "C" SDL_TLSData * SDL_SYS_GetTLSData()