[emscripten] Use emterpreter

This allows us to control the runloop
This commit is contained in:
Romain Goyet
2018-02-01 12:01:12 +01:00
committed by EmilieNumworks
parent fd7516f8ac
commit 67f082f4e8
10 changed files with 31 additions and 25 deletions

View File

@@ -18,12 +18,12 @@ Timer * RunLoop::timerAtIndex(int i) {
}
void RunLoop::run() {
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop_arg([](void * ctx){ ((RunLoop *)ctx)->step(); }, this, 0, 1);
#else
while(step()) {
runWhile(nullptr, nullptr);
}
void RunLoop::runWhile(bool (*callback)(void * ctx), void * ctx) {
while ((callback == nullptr || callback(ctx)) && step()) {
}
#endif
}
bool RunLoop::step() {