Kevin Gadd (2013-04-21T22:33:36.000Z)
github at esdiscuss.org (2013-07-12T02:26:59.625Z)
For some subset of use cases I imagine shared-memory multithreading being limited to immutable objects could do the trick. Of course, I don't know if real immutability is actually possible in ES as currently specified - if I called `Object.freeze` or `Object.seal` on a JS object would it actually be safe to pass it to another thread and let both threads use it without any locking or guards? I imagine there are probably subtle gotchas here where 'read' operations could end up mutating state and causing threads to trip over each other. Presumably this has already been considered for transferring objects to web workers as well, i.e. if the object is known immutable, it can be 'shared' with the worker without a copy. Combining a graph of immutable objects (like a source AST or scene graph or something like that) with a transferable arraybuffer would let you tackle lots of use cases, I think, without as many downsides as true shared-memory threading. But I don't know if that addresses enough use cases to merit the effort.