include/SDL_thread.h
changeset 5969 3a041d215edc
parent 5904 a21d78fc998c
child 6138 4c64952a58fb
     1.1 --- a/include/SDL_thread.h	Tue Sep 27 23:16:04 2011 -0400
     1.2 +++ b/include/SDL_thread.h	Sun Oct 02 00:29:16 2011 -0400
     1.3 @@ -102,7 +102,7 @@
     1.4   *  Create a thread.
     1.5   */
     1.6  extern DECLSPEC SDL_Thread *SDLCALL
     1.7 -SDL_CreateThread(SDL_ThreadFunction fn, void *data,
     1.8 +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
     1.9                   pfnSDL_CurrentBeginThread pfnBeginThread,
    1.10                   pfnSDL_CurrentEndThread pfnEndThread);
    1.11  
    1.12 @@ -111,27 +111,51 @@
    1.13  /**
    1.14   *  Create a thread.
    1.15   */
    1.16 -#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL)
    1.17 +#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, NULL, NULL)
    1.18  
    1.19  #else
    1.20  
    1.21  /**
    1.22   *  Create a thread.
    1.23   */
    1.24 -#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
    1.25 +#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, _beginthreadex, _endthreadex)
    1.26  
    1.27  #endif
    1.28  #else
    1.29  
    1.30  /**
    1.31   *  Create a thread.
    1.32 + *
    1.33 + *   Thread naming is a little complicated: Most systems have very small
    1.34 + *    limits for the string length (BeOS has 32 bytes, Linux currently has 16,
    1.35 + *    Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll
    1.36 + *    have to see what happens with your system's debugger. The name should be
    1.37 + *    UTF-8 (but using the naming limits of C identifiers is a better bet).
    1.38 + *   There are no requirements for thread naming conventions, so long as the
    1.39 + *    string is null-terminated UTF-8, but these guidelines are helpful in
    1.40 + *    choosing a name:
    1.41 + *
    1.42 + *    http://stackoverflow.com/questions/149932/naming-conventions-for-threads
    1.43 + *
    1.44 + *   If a system imposes requirements, SDL will try to munge the string for
    1.45 + *    it (truncate, etc), but the original string contents will be available
    1.46 + *    from SDL_GetThreadName().
    1.47   */
    1.48  extern DECLSPEC SDL_Thread *SDLCALL
    1.49 -SDL_CreateThread(SDL_ThreadFunction fn, void *data);
    1.50 +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
    1.51  
    1.52  #endif
    1.53  
    1.54  /**
    1.55 + * Get the thread name, as it was specified in SDL_CreateThread().
    1.56 + *  This function returns a pointer to a UTF-8 string that names the
    1.57 + *  specified thread, or NULL if it doesn't have a name. This is internal
    1.58 + *  memory, not to be free()'d by the caller, and remains valid until the
    1.59 + *  specified thread is cleaned up by SDL_WaitThread().
    1.60 + */
    1.61 +extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread);
    1.62 +
    1.63 +/**
    1.64   *  Get the thread identifier for the current thread.
    1.65   */
    1.66  extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void);