threads: Move SDL's own thread creation to a new internal API.
This allows us to set an explicit stack size (overriding the system default and the global hint an app might have set), and remove all the macro salsa for dealing with _beginthreadex and such, as internal threads always set those to NULL anyhow. I've taken some guesses on reasonable (and tiny!) stack sizes for our internal threads, but some of these might turn out to be too small in practice and need an increase. Most of them are simple functions, though.
This commit is contained in:
parent
db39f16823
commit
2ef7fa3e3a
13 changed files with 44 additions and 68 deletions
|
@ -60,6 +60,11 @@ extern SDL_TLSData *SDL_SYS_GetTLSData();
|
|||
/* Set the thread local storage for this thread */
|
||||
extern int SDL_SYS_SetTLSData(SDL_TLSData *data);
|
||||
|
||||
/* This is for internal SDL use, so we don't need #ifdefs everywhere. */
|
||||
extern SDL_Thread *
|
||||
SDL_CreateThreadInternal(int (SDLCALL * fn) (void *), const char *name,
|
||||
const size_t stacksize, void *data);
|
||||
|
||||
#endif /* _SDL_systhread_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -423,6 +423,16 @@ SDL_CreateThread(int (SDLCALL * fn) (void *),
|
|||
#endif
|
||||
}
|
||||
|
||||
SDL_Thread *
|
||||
SDL_CreateThreadInternal(int (SDLCALL * fn) (void *), const char *name,
|
||||
const size_t stacksize, void *data) {
|
||||
#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
||||
return SDL_CreateThreadWithStackSize(fn, name, stacksize, data, NULL, NULL);
|
||||
#else
|
||||
return SDL_CreateThreadWithStackSize(fn, name, stacksize, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_threadID
|
||||
SDL_GetThreadID(SDL_Thread * thread)
|
||||
{
|
||||
|
|
|
@ -90,19 +90,6 @@ extern SDL_TLSData *SDL_Generic_GetTLSData();
|
|||
*/
|
||||
extern int SDL_Generic_SetTLSData(SDL_TLSData *data);
|
||||
|
||||
/* !!! FIXME: for 2.1, remove this and make stack size part of SDL_CreateThread. */
|
||||
#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
||||
SDL_Thread *SDLCALL
|
||||
SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
|
||||
const char *name, const size_t stacksize, void *data,
|
||||
pfnSDL_CurrentBeginThread pfnBeginThread,
|
||||
pfnSDL_CurrentEndThread pfnEndThread)
|
||||
#else
|
||||
SDL_Thread *SDLCALL
|
||||
SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
|
||||
const char *name, const size_t stacksize, void *data)
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_thread_c_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue