Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/test/doublestart.c
4128 views
1
/*
2
* Copyright 2014 The Emscripten Authors. All rights reserved.
3
* Emscripten is available under two separate licenses, the MIT license and the
4
* University of Illinois/NCSA Open Source License. Both these licenses can be
5
* found in the LICENSE file.
6
*/
7
8
#include <stdio.h>
9
#include <emscripten.h>
10
11
int times = 0;
12
13
void later(void* nada) {
14
REPORT_RESULT(times);
15
}
16
17
void main_loop(void) {
18
static int cnt = 0;
19
if (++cnt >= 10) emscripten_cancel_main_loop();
20
}
21
22
int main(void) {
23
emscripten_async_call(later, NULL, 2000);
24
times++;
25
printf("This should only appear once.\n");
26
emscripten_set_main_loop(main_loop, 10, 0);
27
return 0;
28
}
29
30