On 6/26/20 5:20 AM, Jan de Mooij wrote:
> On Fri, Jun 26, 2020 at 9:40 AM Miles <miles.t...@arup.com
>> Only being able to have a single Context per thread seems to be a backward
>> step to me and it's going to be a massive problem for our embedding.
>> What was the rationale behind requiring it and do I have any alternatives
>> other than making each Context a separate thread?
> We used to depend on having multiple contexts per runtime in Gecko, but it
> was really hard to reason about them because it wasn't very clear what a
> JSContext represented exactly. So this was simplified to just having one
> context per runtime / thread. Can you say more about why your embedding
> need multiple contexts? What doesn't work if you create one context?
You can still do a runtime per thread. They will be completely isolated
from each other. (Well, there's some limited sharing you can do by
having one toplevel runtime that all the other runtimes parent to, but
that's for very limited read-only constant data IIUC.)
If you need them to communicate with each other, you'd have to create a
messaging system to send JSON data (for very simply structured data) or
structured clone buffers between them. Or I suppose these days you could
also use SharedArrayBuffers and Atomics, but that'd only be for plain
bits, not objects or strings or any other GC things.