Path: blob/main/test/browser/async_virtual.cpp
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 <assert.h>6#include <stdio.h>7#include <emscripten.h>89class BatchFile {10public:11virtual int ReadLine(char * line);12};1314int BatchFile::ReadLine(char * line) {15printf("Sleep-->\n");16emscripten_sleep(300);17printf("<--Sleep\n");18return 1;19}2021BatchFile b;2223BatchFile *bf = &b;2425int main(void) {26printf("main.\n");27int cnt = 0;28int result = 0;29while (cnt < 5) {30printf("main loop %i\n", ++cnt);31result += bf->ReadLine(0);32}33assert(result == 5);34return 0;35}36373839