WinRT: implemented SDL_DetachThread() for WinRT
authorDavid Ludwig <dludwig@pobox.com>
Thu, 28 Nov 2013 22:24:13 -0500
changeset 8544 356878e614e2
parent 8543 b9dd3cf38585
child 8545 7cf4f8916997
WinRT: implemented SDL_DetachThread() for WinRT
src/thread/stdcpp/SDL_systhread.cpp
--- a/src/thread/stdcpp/SDL_systhread.cpp	Thu Nov 28 22:09:21 2013 -0500
+++ b/src/thread/stdcpp/SDL_systhread.cpp	Thu Nov 28 22:24:13 2013 -0500
@@ -131,6 +131,26 @@
 }
 
 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()
 {