Subj : JS_ResumeRequest puzzle To : netscape.public.mozilla.jseng From : Bob Kline Date : Wed Mar 17 2004 11:46 am I'm trying to apply the generous advice we've received over the past few days on making the Sabltron XSL/T package's use of SpiderMonkey thread-safe. The latest snag is a compilation failure: .....jsext.cpp(465) : error C2660: 'JS_ResumeRequest' : function does not take 1 arguments Lines 464-466 have: #ifdef JS_THREADSAFE JS_ResumeRequest(cx); #endif where cx is declared as JSContext*. Here's what the documentation says for JS_ResumeRequest: ===================================================================== JS_ResumeRequest Function Summary Restarts a previously suspended thread. Syntax void JS_ResumeRequest(JSContext *cx); Description When your application restart a previously suspended thread, JS_BeginRequest safely increments the thread counter for the JS engine runtime associated with a given context, cx. In order to increment the counter, this function first checks that garbage collection is not in process. If it is, JS_ResumeRequest waits until garbage collection is complete before locking the JS engine runtime and incrementing the thread counter. After incrementing the counter, JS_ResumeRequest unlocks the runtime if it previously locked it. Notes JS_ResumeRequest is only available if you compile the JS engine with JS_THREADSAFE defined. In a default engine compilation, JS_THREADSAFE is undefined. ===================================================================== Can I get around this problem by avoiding JS_SuspendRequest and JS_ResumeRequest altogether, replacing: JS_BeginRequest(cx); JS_XXX(); JS_YYY(); JS_SuspendRequest(cx); BlockingOperation(); JS_ResumeRequest(cx); JS_ZZZ(); JS_EndRequest(cx); with JS_BeginRequest(cx); JS_XXX(); JS_YYY(); JS_EndRequest(cx); BlockingOperation(); JS_BeginRequest(cx); JS_ZZZ(); JS_EndRequest(cx); on the assumption that these two blocks of code are functionally equivalent to each other? Or is my understanding of the request model still not incorporating all of the subtleties? Also, one more further clarification. Brendan corrected one of the things I said the other day, pointing out that it is not *necessary* to put the JS_GC() and JS_MaybeGC() calls outside of the request blocks. Does that also mean that it is not *allowed* as well, or is it safe to put the GC calls anywhere? Thanks again! Bob .