Re: Suspend worker thread when in background

Daniel Gibson <[email protected]> Fri, 20 Jan 2017 01:05:02 +0100
Newsgroups gmane.comp.lib.sdl
Message-ID <[email protected]>
Err.. about what kind of time spans are we talking here?
memcpy() taking a "long" amount of time seems very weird to me.
Even if it takes like a second until all threads are suspended (or maybe 
even a few seconds?) that shouldn't be a problem?

On 20.01.2017 00:31, rtrussell wrote:
>
> 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
>