[SDL] Not calling functions within a Timer Callback ?
rainerd at eldwood.com
Tue May 11 10:14:27 PDT 2004
Luke J Crook wrote:
> "The timer callback function may run in a different thread than your
> main program, and so shouldn't call any functions from within itself.
Worse, it may run as an interrupt on some operating systems, which further
restricts what you can do.
> Does this mean that no functions (even user defined or standard C
> functions) may be called from within a callback ? Only C statements,
> conditionals (like + -, if switch while etc. ) are allowed ?
SDL functions are not allowed unless otherwise noted.
OS functions may or may not be allowed depending on the OS.
C/C++ standard library functions may or may not be allowed depending on the
Shared data (global/static variables) may be read from multiple threads so
long as there is no chance that any thread is writing to it. Alternately, a
mutex may be used to protect access (both read and write) to that data.
Mutexes cannot be used if the timer runs as an interrupt. See the SDL
User-defined functions are allowed, so long as their content follows the
rules given above.
The same rules apply if you create a thread by any other means, including
through the SDL threading functions.
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com
More information about the SDL