With the upcoming SharedArrayBuffer specification,
https://tc39.github.io/ecmascript_sharedmem/shmem.html, there will be a
very efficient no-copy way of communicating the data between workers by
allowing multiple workers to access the same typed array simultaneously.
The current Emscripten pthreads
My question was not clear previously. I clarified and posted it here:
http://stackoverflow.com/questions/40916582/how-to-interact-with-an-emscripten-web-worker-directly-from-a-javascript-front
I am looking for a solution to efficiently communicate with an
Emscripten-compiled Web Worker from a nat
You should be able to pass arguments as an array to support multiples.
For calling a function with an arbitrary-length array of parameters on the
worker end, try the Function.apply method:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
var func =
Thank you. I started to implement based on your suggestion.
I compiled my C++ file using -s BUILD_AS_WORKER=1. On the JS side, I chose
the right function on the C++ through a dictionary:
var worker = new Worker('compiled.js');
worker.postMessage({ funcName: "c_func", callbackId: -1 /* id used when
I have a comparable setup in the ogv.js media player:
On the main thread I have a JS front-end and an emscripten C module for the
demuxer, which extracts packets of compressed data to be sent to Workers
with additional emscripten C modules which decode the data and send back
uncompressed video or