1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include <emscripten.h>
#include <stdio.h>
EM_JS_DEPS(main, "$runtimeKeepalivePush,$runtimeKeepalivePop,$callUserCallback");
int main() {
EM_ASM({
Module["onExit"] = () => { out("onExit"); };
runtimeKeepalivePush();
out("runtimeKeepalivePush done");
counter = 0;
function timerCallback() {
if (counter < 5) {
runtimeKeepalivePush();
out("runtimeKeepalivePush done");
} else {
runtimeKeepalivePop();
out("runtimeKeepalivePop done");
}
counter += 1;
callUserCallback(() => {
out("in user callback: " + counter);
}, 0);
if (!runtimeExited) {
setTimeout(timerCallback, 0);
}
}
setTimeout(timerCallback, 0);
});
puts("returning from main");
return 0;
}
|