Revision 8b67982bf0af32ffa48c6cf6355d7d86cdb0817d authored by Alon Zakai on 10 March 2014, 17:12:32 UTC, committed by Alon Zakai on 10 March 2014, 17:12:32 UTC
2 parent s 8658790 + 99a8cf5
Raw File
worker_api_2_worker.cpp
#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));
}

}

back to top