summaryrefslogtreecommitdiffstats
path: root/uisimulator/sdl/thread-sdl.c
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/sdl/thread-sdl.c')
-rw-r--r--uisimulator/sdl/thread-sdl.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/uisimulator/sdl/thread-sdl.c b/uisimulator/sdl/thread-sdl.c
index ab1086dd7d..1522f318a6 100644
--- a/uisimulator/sdl/thread-sdl.c
+++ b/uisimulator/sdl/thread-sdl.c
@@ -64,15 +64,18 @@ extern long start_tick;
void thread_sdl_shutdown(void)
{
int i;
- /* Take control */
- SDL_LockMutex(m);
/* Tell all threads jump back to their start routines, unlock and exit
gracefully - we'll check each one in turn for it's status. Threads
_could_ terminate via remove_thread or multiple threads could exit
on each unlock but that is safe. */
+
+ /* Do this before trying to acquire lock */
threads_exit = true;
+ /* Take control */
+ SDL_LockMutex(m);
+
for (i = 0; i < MAXTHREADS; i++)
{
struct thread_entry *thread = &threads[i];
@@ -200,6 +203,16 @@ bool thread_sdl_init(void *param)
return true;
}
+void thread_sdl_exception_wait(void)
+{
+ while (1)
+ {
+ SDL_Delay(HZ/10);
+ if (threads_exit)
+ thread_exit();
+ }
+}
+
/* A way to yield and leave the threading system for extended periods */
void thread_sdl_thread_lock(void *me)
{