riscos: Fix thread starvation in fullscreen mode SDL-1.2
authorJeffrey Lee <me@phlamethrower.co.uk>
Fri, 31 May 2019 00:22:44 +0100
branchSDL-1.2
changeset 1278476a69405319c
parent 12783 de7c0427180c
child 12785 1b8374f29699
riscos: Fix thread starvation in fullscreen mode
src/video/riscos/SDL_riscosevents.c
     1.1 --- a/src/video/riscos/SDL_riscosevents.c	Sat Jun 01 19:26:50 2019 +0100
     1.2 +++ b/src/video/riscos/SDL_riscosevents.c	Fri May 31 00:22:44 2019 +0100
     1.3 @@ -44,6 +44,10 @@
     1.4  #include "kernel.h"
     1.5  #include "swis.h"
     1.6  
     1.7 +#if !SDL_THREADS_DISABLED
     1.8 +#include <pthread.h>
     1.9 +#endif
    1.10 +
    1.11  /* The translation table from a RISC OS internal key numbers to a SDL keysym */
    1.12  static SDLKey RO_keymap[SDLK_LAST];
    1.13  
    1.14 @@ -83,6 +87,9 @@
    1.15  /* Timer running function */
    1.16  extern void RISCOS_CheckTimer();
    1.17  
    1.18 +#else
    1.19 +extern int riscos_using_threads;
    1.20 +
    1.21  #endif
    1.22  
    1.23  void FULLSCREEN_PumpEvents(_THIS)
    1.24 @@ -93,6 +100,14 @@
    1.25  #if SDL_THREADS_DISABLED
    1.26  //	DRenderer_FillBuffers();
    1.27  	if (SDL_timer_running) RISCOS_CheckTimer();
    1.28 +#else
    1.29 +	/* Stop thread starvation, which will occur if the main loop
    1.30 +         doesn't call SDL_Delay */
    1.31 +	if (riscos_using_threads)
    1.32 +	{
    1.33 +		pthread_yield();
    1.34 +	}
    1.35 +
    1.36  #endif
    1.37  }
    1.38