aboutsummaryrefslogtreecommitdiff
path: root/tests/doublestart.c
blob: 533e6308453a320b2f1453ed172e19fa325d82d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <emscripten.h>

int times = 0;

void later(void* nada) {
  int result = times;
  REPORT_RESULT();
}

void main_loop(void) {
  static int cnt = 0;
  if (++cnt >= 10) emscripten_cancel_main_loop();
}

int main(void) {
  emscripten_async_call(later, NULL, 2000);
  times++;
  printf("This should only appear once.\n");
  emscripten_set_main_loop(main_loop, 10, 0);
  return 0;
}