4 ms·
This appears to be based on completely isolated runtimes. Note this line from fibonacci-recursive: // Broadcast function declaration of 'fibonacci' to napa
by ridiculous_fish 4y ago
This appears to be based on completely isolated runtimes. Note this line from fibonacci-recursive:
// Broadcast function declaration of 'fibonacci' to napa workers.
zone.broadcast(fibonacci.toString());
This "serializes" the function `fibonacci` as a string (!) and then `eval`s it in all the workers; this has some obvious limitations. Anyways about the same level as WebWorker.
Filip Pizlo probably has outlined the best attempt at how real multithreaded JS might work: https://webkit.org/blog/7846/concurrent-javascript-it-can-work/ https://webkit.org/blog/7846/concurrent-javascript-it-can-wo...
- esailija 4y agoYeah, this could have been a small npm package for node. Node already supports workers that communicate with serialization or shared array buffers+locks.
- fulafel 4y agoIn https://github.com/microsoft/napajs/blob/master/docs/api/transport.md#transportable-types https://github.com/microsoft/napajs/blob/master/docs/api/tra... it sounds like there aren't completely isolated runtimes - "JavaScript standard built-in objects in the whitelist can be transported among napa workers transparently" and it seems to imply they are not transported via serialization but via a sharing mechanism leveraging multiple threads in the same runtime. (And also it talks about implementing your own Transportable classes)