diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-04-17 20:32:14 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-04-17 20:32:14 -0700 |
commit | 735637e9a10049f69525d57d3e50f4ad0b90850e (patch) | |
tree | 54c28b89f4eff2d734b5907dc1b5fef92ea23969 /system | |
parent | 74690aa7e9dba5d729264536a6610120afa36315 (diff) |
add emscripten_async_call
Diffstat (limited to 'system')
-rw-r--r-- | system/include/emscripten.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/system/include/emscripten.h b/system/include/emscripten.h index ea078e8c..7bb2ae8e 100644 --- a/system/include/emscripten.h +++ b/system/include/emscripten.h @@ -28,6 +28,21 @@ extern void emscripten_set_main_loop(void (*func)(), int fps); extern void emscripten_cancel_main_loop(); /* + * Call a C function asynchronously, that is, after returning + * control to the JS event loop. This is done by a setTimeout. + * When building natively this becomes a simple direct call, + * after SDL_Delay (you must include SDL.h for that). + */ +#if EMSCRIPTEN +extern void emscripten_async_call(void (*func)(), int millis); +#else +void emscripten_async_call(void (*func)(), int millis) { + SDL_Delay(millis); + func(); +} +#endif + +/* * This macro-looking function will cause Emscripten to * generate a comment in the generated code. * XXX This is deprecated for now, because it requires us to |