arudradey/ml-cpu-storage / emsdk /upstream /emscripten /test /emscripten_api_browser_infloop.cpp
arudradey's picture
download
raw
1.32 kB
// Copyright 2012 The Emscripten Authors. All rights reserved.
// Emscripten is available under two separate licenses, the MIT license and the
// University of Illinois/NCSA Open Source License. Both these licenses can be
// found in the LICENSE file.
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <emscripten.h>
struct Class {
static Class *instance;
int x;
Class() : x(0) {}
~Class() {
// Destructor should never be called.
assert(false);
x = -9999;
}
void print() {
printf("waka %d\n", x++);
if (x == 7 || x < 0) {
emscripten_cancel_main_loop();
exit(x == 7 ? 0 : 1);
}
}
static void callback() {
instance->print();
}
void start() {
instance = this;
EM_ASM({
var initial = stackSave();
out('seeing initial stack of ' + initial);
setTimeout(function() {
var current = stackSave();
out('seeing later stack of ' + current);
assert(current === initial);
}, 0);
});
// important if we simulate an infinite loop here or not. With an infinite loop, the
// destructor should *NOT* have been called
emscripten_set_main_loop(Class::callback, 3, 1);
}
};
Class *Class::instance = NULL;
int main() {
Class().start();
return 99;
}

Xet Storage Details

Size:
1.32 kB
·
Xet hash:
19bde8aeca579918c473e13f3d06478241ff628ca09837e3ea75e88d1a44b9d7

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.