Re: Recommended practice for transfer of C++ large arrays from web worker to JavaScript in an HTML

2016-12-03 Thread Jukka Jylänki
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

Re: Recommended practice for transfer of C++ large arrays from web worker to JavaScript in an HTML

2016-12-01 Thread Sohail Siadat
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

Re: Recommended practice for transfer of C++ large arrays from web worker to JavaScript in an HTML

2016-11-04 Thread Brion Vibber
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 =

Re: Recommended practice for transfer of C++ large arrays from web worker to JavaScript in an HTML

2016-11-04 Thread Sohail Siadat
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

Re: Recommended practice for transfer of C++ large arrays from web worker to JavaScript in an HTML

2016-06-17 Thread Brion Vibber
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