include/SDL_thread.h
changeset 5969 3a041d215edc
parent 5904 a21d78fc998c
child 6138 4c64952a58fb
equal deleted inserted replaced
5968:b229328c7ad4 5969:3a041d215edc
   100 
   100 
   101 /**
   101 /**
   102  *  Create a thread.
   102  *  Create a thread.
   103  */
   103  */
   104 extern DECLSPEC SDL_Thread *SDLCALL
   104 extern DECLSPEC SDL_Thread *SDLCALL
   105 SDL_CreateThread(SDL_ThreadFunction fn, void *data,
   105 SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
   106                  pfnSDL_CurrentBeginThread pfnBeginThread,
   106                  pfnSDL_CurrentBeginThread pfnBeginThread,
   107                  pfnSDL_CurrentEndThread pfnEndThread);
   107                  pfnSDL_CurrentEndThread pfnEndThread);
   108 
   108 
   109 #if defined(_WIN32_WCE)
   109 #if defined(_WIN32_WCE)
   110 
   110 
   111 /**
   111 /**
   112  *  Create a thread.
   112  *  Create a thread.
   113  */
   113  */
   114 #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL)
   114 #define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, NULL, NULL)
   115 
   115 
   116 #else
   116 #else
   117 
   117 
   118 /**
   118 /**
   119  *  Create a thread.
   119  *  Create a thread.
   120  */
   120  */
   121 #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
   121 #define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, _beginthreadex, _endthreadex)
   122 
   122 
   123 #endif
   123 #endif
   124 #else
   124 #else
   125 
   125 
   126 /**
   126 /**
   127  *  Create a thread.
   127  *  Create a thread.
       
   128  *
       
   129  *   Thread naming is a little complicated: Most systems have very small
       
   130  *    limits for the string length (BeOS has 32 bytes, Linux currently has 16,
       
   131  *    Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll
       
   132  *    have to see what happens with your system's debugger. The name should be
       
   133  *    UTF-8 (but using the naming limits of C identifiers is a better bet).
       
   134  *   There are no requirements for thread naming conventions, so long as the
       
   135  *    string is null-terminated UTF-8, but these guidelines are helpful in
       
   136  *    choosing a name:
       
   137  *
       
   138  *    http://stackoverflow.com/questions/149932/naming-conventions-for-threads
       
   139  *
       
   140  *   If a system imposes requirements, SDL will try to munge the string for
       
   141  *    it (truncate, etc), but the original string contents will be available
       
   142  *    from SDL_GetThreadName().
   128  */
   143  */
   129 extern DECLSPEC SDL_Thread *SDLCALL
   144 extern DECLSPEC SDL_Thread *SDLCALL
   130 SDL_CreateThread(SDL_ThreadFunction fn, void *data);
   145 SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
   131 
   146 
   132 #endif
   147 #endif
       
   148 
       
   149 /**
       
   150  * Get the thread name, as it was specified in SDL_CreateThread().
       
   151  *  This function returns a pointer to a UTF-8 string that names the
       
   152  *  specified thread, or NULL if it doesn't have a name. This is internal
       
   153  *  memory, not to be free()'d by the caller, and remains valid until the
       
   154  *  specified thread is cleaned up by SDL_WaitThread().
       
   155  */
       
   156 extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread);
   133 
   157 
   134 /**
   158 /**
   135  *  Get the thread identifier for the current thread.
   159  *  Get the thread identifier for the current thread.
   136  */
   160  */
   137 extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void);
   161 extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void);