On 3 February 2012 16:24, Dave Mandelin <
dman...@mozilla.com> wrote:
> I wish I knew more about how multiple contexts are being used. Are you
> talking about using cx1 and cx2 from threads T1 and T2, or something
> else?
>
There are several patterns in use in embeddings which aren't in use in the
browser. I'm trying to think of a few examples, if I'm slightly
incoherent it's because I am currently nearly decaffeinated. :)
One pattern is where multiple contexts are on the go, with only one running
at any time, supporting separate applications, with separate global
variables. Think of, say, a web server running multiple applications.
They need to be in the same runtime because they can share objects, but
they need to be in different contexts because ... I dunno...maybe they need
different standard classes for security sandboxing?
Mike Moening uses a pattern something like that, ISTR he keeps
pre-initialized cx's around so that his server can handle connections
quickly. Maybe Mike can chime in here, is there a way to link him to this
thread if he is not on the list?
Another is where you have a debugger written in JS debugging JS programs.
You don't want the debugger and the debuggee running in the same context.
In GPSEE, we have to keep an extra context around on the main thread for
some reason, too. I forget the exact details at the moment. I think it's
because we need to JS_free() memory after all our JS code has been garbage
collected, and the only way to insure that the garbage gets collected is to
destroy the context.
Wes