| 16 | int nesting = 0; |
| 17 | |
| 18 | void iter() { |
| 19 | printf("frame: %d\n", ++counter); |
| 20 | |
| 21 | // ensure we don't 'recurse' with the main loop sending us back in before the |
| 22 | // synchronous operation callback finishes the rest of this trace |
| 23 | assert(nesting == 0); |
| 24 | nesting++; |
| 25 | emscripten_sleep(500); |
| 26 | assert(nesting == 1); |
| 27 | nesting = 0; |
| 28 | |
| 29 | if (counter == 10) { |
| 30 | finish(121); // if we got here without hitting any assertions, all is well |
| 31 | emscripten_cancel_main_loop(); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | int main() { |
| 36 | emscripten_set_main_loop(iter, 0, 0); |