You'd rather have one top-level scope per script execution. Otherwise,
all threads would share their top-level variables (incl. JS built-in
objects).
What you can do - if you really want and are worried about performance
of initializing standard objects for each script execution - is to
create one scope with initStandardObjects(), seal it, and then use it
as the prototype of the per-thread scopes; that way, all thread-
specific top-level scopes will inherit the standard objects (String,
Number, Date, Error, RegExp, etc.) through the prototype scope. That
still means threads share the standard objects, but unless they mutate
them somehow, you should be safe. However, top-level variables won't
be shared, and that's crucial.
Attila.
On 2009.01.27., at 17:41, George Moschovitis wrote:
Two questions:
- using the same scope for all threads isn't problematic?
In my current servlet I keep a scope per thread (using a thread
local variable). I think this better isolates the threads from each
other. Is this unnecessary?
- is Simple actively maintained?
-g.
On Jan 23, 3:45 pm, Tom Robinson <[email protected]> wrote:
I'm doing pretty much the same thing (starting up Jetty/Simple within
the Rhino shell) in the Jack project (like Ruby's Rack for
JavaScript:http://github.com/tlrobinson/jack). I've briefly tried
some concurrent
requests, and as far as I can tell there's no problem, it just works.
Multiple concurrent requests use the same scope, and I assume
different contexts as you've mentioned.
Also, I just added Simple support to
Jack:http://github.com/tlrobinson/jack/tree/master/lib/jack/handler/simple.js
You should consider using Jack ;)
It lets you easily run your applications on a number of web servers
(right now it supports Simple and servlet containers, including
Jetty), and use various pieces of middleware.
It's brand new, but it's quite simple. The whole thing, including a
bunch of middleware and all the adapters, is less than 1000 LOC. Like
Rack and WSGI it's mostly just a protocol, but for JavaScript.
On Jan 23, 3:55 am, Patrick Dobbs <[email protected]>
wrote:
My understanding is that if you start the webserver from Rhino, then
there is only one Scope which is shared between Threads/Contexts.
I'm currently adding some logging / debugging statements to the
Rhino
codebase to check what is going on (ie when Contexts are getting
created). I'll post again if my findings suggest anything different.
George Moschovitis wrote:
OK, Rhino seems to support multithreading (ie multiple Contexts).
What
about scopes?
Do all the threads use the same scope?
-g.
On Jan 22, 10:50 pm, Patrick Dobbs
<[email protected]>
wrote:
Norris Boyd wrote:
Thanks to Norris for his pointers. Assuming these
interpretations are
...
correct, I'll shut up now.
Patrick
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino