Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/test/browser/async_virtual.cpp
4150 views
1
// Copyright 2015 The Emscripten Authors. All rights reserved.
2
// Emscripten is available under two separate licenses, the MIT license and the
3
// University of Illinois/NCSA Open Source License. Both these licenses can be
4
// found in the LICENSE file.
5
6
#include <assert.h>
7
#include <stdio.h>
8
#include <emscripten.h>
9
10
class BatchFile {
11
public:
12
virtual int ReadLine(char * line);
13
};
14
15
int BatchFile::ReadLine(char * line) {
16
printf("Sleep-->\n");
17
emscripten_sleep(300);
18
printf("<--Sleep\n");
19
return 1;
20
}
21
22
BatchFile b;
23
24
BatchFile *bf = &b;
25
26
int main(void) {
27
printf("main.\n");
28
int cnt = 0;
29
int result = 0;
30
while (cnt < 5) {
31
printf("main loop %i\n", ++cnt);
32
result += bf->ReadLine(0);
33
}
34
assert(result == 5);
35
return 0;
36
}
37
38
39