Closed
Bug 686230
Opened 12 years ago
Closed 12 years ago
JSCallOnce
Categories
(Core :: JavaScript Engine, enhancement)
Tracking
()
RESOLVED
FIXED
mozilla10
People
(Reporter: sfink, Unassigned)
Details
Attachments
(1 file)
3.48 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
I've been doing a number of things within the JS engine where I'm integrating with external libraries that want a per-process initialization. For example, opagent's op_open_agent() ends up creating a file named after the current pid. As far as I can tell, there is no way to do this sort of module initialization safely from within the JS engine. You can't use a global lock because NSPR (and probably some underlying thread libraries) does not provide a static initializer, so the creation of the global lock itself races. If we had a JS_StartEngine() that was required to be called before starting up any more JSAPI-using threads, I could hook in there, but we don't. I finally stumbled across NSPR's solution: PR_CallOnce. (I should've grepped for pthread_once in the first place; it was very hard to find.) I think we should have a JS wrapper for the same functionality. (I've been using a static initialization flag from within JS_NewRuntime, but there's no restriction as far as I know on a single runtime per process.)
Reporter | ||
Comment 1•12 years ago
|
||
I'm not crazy about the names in this patch, and I haven't actually tested the !JS_THREADSAFE case.
Attachment #559784 -
Flags: review?(luke)
![]() |
||
Comment 2•12 years ago
|
||
Comment on attachment 559784 [details] [diff] [review] Add JS_CallOnce to the JSAPI for module initialization r+ with beefy comment in jsapi.h explaining the interface, in particular, the 'once' arg.
Attachment #559784 -
Flags: review?(luke) → review+
Reporter | ||
Comment 3•12 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/74c8bc479d72
Comment 4•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/74c8bc479d72
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
You need to log in
before you can comment on or make changes to this bug.
Description
•