WinRT: implemented SDL_DetachThread() for WinRT
authorDavid Ludwig <dludwig@pobox.com>
Thu, 28 Nov 2013 22:24:13 -0500
changeset 8544356878e614e2
parent 8543 b9dd3cf38585
child 8545 7cf4f8916997
WinRT: implemented SDL_DetachThread() for WinRT
src/thread/stdcpp/SDL_systhread.cpp
     1.1 --- a/src/thread/stdcpp/SDL_systhread.cpp	Thu Nov 28 22:09:21 2013 -0500
     1.2 +++ b/src/thread/stdcpp/SDL_systhread.cpp	Thu Nov 28 22:24:13 2013 -0500
     1.3 @@ -131,6 +131,26 @@
     1.4  }
     1.5  
     1.6  extern "C"
     1.7 +void
     1.8 +SDL_SYS_DetachThread(SDL_Thread * thread)
     1.9 +{
    1.10 +    if ( ! thread) {
    1.11 +        return;
    1.12 +    }
    1.13 +
    1.14 +    try {
    1.15 +        std::thread * cpp_thread = (std::thread *) thread->handle;
    1.16 +        if (cpp_thread->joinable()) {
    1.17 +            cpp_thread->detach();
    1.18 +        }
    1.19 +    } catch (std::system_error &) {
    1.20 +        // An error occurred when detaching the thread.  SDL_DetachThread does not,
    1.21 +        // however, seem to provide a means to report errors to its callers
    1.22 +        // though!
    1.23 +    }
    1.24 +}
    1.25 +
    1.26 +extern "C"
    1.27  SDL_TLSData *
    1.28  SDL_SYS_GetTLSData()
    1.29  {