Re: Suspend worker thread when in background

"rtrussell" <[email protected]> Thu, 19 Jan 2017 23:31:33 +0000
Newsgroups gmane.comp.lib.sdl
Message-ID <[email protected]>
Daniel Gibson wrote:
> You could use SDL_CondWait in the worker threads

I'm already doing the equivalent, but since it's a 'polling' approach (the thread will only be suspended when it next calls SDL_CondWait) and my worker thread does some quite time-consuming things (it might even be in a lengthy memcpy), I cannot guarantee that it will be suspended in a timely fashion.  It works most of the time, but my app still crashes intermittently when Android puts it into the background.

Google seems to suggest that asynchronously suspending a thread in Android is deprecated (http://stackoverflow.com/questions/10189289/how-to-suspend-and-resume-threads-in-android), and one should indeed use the kind of polling approach you are advocating.  But I don't understand how that can meet the requirement to respond to the SDL_APP_WILLENTERBACKGROUND event 'immediately'.

Richard.

_______________________________________________
SDL mailing list
[email protected]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org