1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
// 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 <emscripten.h>
struct Info {
int i;
float f;
char c;
double d;
};
int calls = 0; // global state that is not in all workers
extern "C" {
void one(char *data, int size) {
calls++;
emscripten_worker_respond(data, size);
}
void two(char *data, int size) {
calls++;
Info *x = (Info*)data;
x[0].i++;
x[0].f--;
x[0].c++;
x[0].d--;
emscripten_worker_respond(data, size);
}
void three(char *data, int size) {
assert(data == 0);
assert(size == 0);
calls++;
// no response
}
void four(char *data, int size) {
assert(data == 0);
assert(size == 0);
emscripten_worker_respond((char*)&calls, sizeof(calls));
}
}
|