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:
Ryan C. Gordon
2016-04-12 16:45:10 -04:00
parent 7ae2951fca
commit c61675dc5d
13 changed files with 44 additions and 68 deletions

View File

@@ -34,9 +34,9 @@
#include "SDL_events.h"
#include "SDL_error.h"
#include "SDL_thread.h"
#include "SDL_mutex.h"
#include "SDL_timer.h"
#include "../thread/SDL_systhread.h"
/* Current pad state */
static SceCtrlData pad = { .Lx = 0, .Ly = 0, .Buttons = 0 };
@@ -116,7 +116,7 @@ int SDL_SYS_JoystickInit(void)
return SDL_SetError("Can't create input semaphore");
}
running = 1;
if((thread = SDL_CreateThread(JoystickUpdate, "JoySitckThread",NULL)) == NULL) {
if((thread = SDL_CreateThreadInternal(JoystickUpdate, "JoystickThread", 4096, NULL)) == NULL) {
return SDL_SetError("Can't create input thread");
}

View File

@@ -35,13 +35,13 @@
#include "SDL_error.h"
#include "SDL_assert.h"
#include "SDL_events.h"
#include "SDL_thread.h"
#include "SDL_timer.h"
#include "SDL_mutex.h"
#include "SDL_events.h"
#include "SDL_hints.h"
#include "SDL_joystick.h"
#include "../SDL_sysjoystick.h"
#include "../thread/SDL_systhread.h"
#if !SDL_EVENTS_DISABLED
#include "../../events/SDL_events_c.h"
#endif
@@ -301,18 +301,9 @@ SDL_SYS_JoystickInit(void)
SDL_SYS_JoystickDetect();
if (!s_threadJoystick) {
s_bJoystickThreadQuit = SDL_FALSE;
/* spin up the thread to detect hotplug of devices */
#if defined(__WIN32__) && !defined(HAVE_LIBC)
#undef SDL_CreateThread
#if SDL_DYNAMIC_API
s_threadJoystick= SDL_CreateThread_REAL(SDL_JoystickThread, "SDL_joystick", NULL, NULL, NULL);
#else
s_threadJoystick= SDL_CreateThread(SDL_JoystickThread, "SDL_joystick", NULL, NULL, NULL);
#endif
#else
s_threadJoystick = SDL_CreateThread(SDL_JoystickThread, "SDL_joystick", NULL);
#endif
s_bJoystickThreadQuit = SDL_FALSE;
s_threadJoystick = SDL_CreateThreadInternal(SDL_JoystickThread, "SDL_joystick", 64 * 1024, NULL);
}
return SDL_SYS_NumJoysticks();
}