Path: blob/main/test/browser/test_async_mainloop.c
4150 views
// Copyright 2015 The Emscripten Authors. All rights reserved.1// Emscripten is available under two separate licenses, the MIT license and the2// University of Illinois/NCSA Open Source License. Both these licenses can be3// found in the LICENSE file.45#include <stdio.h>6#include <emscripten.h>7#include <assert.h>89void finish(int result) {10assert(result == 121);11emscripten_force_exit(0);12}1314int counter = 0;15int nesting = 0;1617void iter() {18printf("frame: %d\n", ++counter);1920// ensure we don't 'recurse' with the main loop sending us back in before the21// synchronous operation callback finishes the rest of this trace22assert(nesting == 0);23nesting++;24emscripten_sleep(500);25assert(nesting == 1);26nesting = 0;2728if (counter == 10) {29finish(121); // if we got here without hitting any assertions, all is well30emscripten_cancel_main_loop();31}32}3334int main() {35emscripten_set_main_loop(iter, 0, 0);36}373839