зеркало из https://github.com/mozilla/gecko-dev.git
Bug 693907 - Once Upon a JSAPI (move JS_CallOnce from jslock.cpp to jsapi.cpp) (r=waldo)
--HG-- extra : rebase_source : 718fa503c0b73f0a4a94f50f28bc4a7981ef4202
This commit is contained in:
Родитель
d24a9afeae
Коммит
a4733c0242
|
@ -6315,3 +6315,27 @@ JS_IndexToId(JSContext *cx, uint32 index, jsid *id)
|
|||
{
|
||||
return IndexToId(cx, index, id);
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
static PRStatus
|
||||
CallOnce(void *func)
|
||||
{
|
||||
JSInitCallback init = JS_DATA_TO_FUNC_PTR(JSInitCallback, func);
|
||||
return init() ? PR_SUCCESS : PR_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_CallOnce(JSCallOnceType *once, JSInitCallback func)
|
||||
{
|
||||
#ifdef JS_THREADSAFE
|
||||
return PR_CallOnceWithArg(once, CallOnce, JS_FUNC_TO_DATA_PTR(void *, func)) == PR_SUCCESS;
|
||||
#else
|
||||
if (!*once) {
|
||||
*once = true;
|
||||
return func();
|
||||
} else {
|
||||
return JS_TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -37,10 +37,6 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jspubtd.h"
|
||||
#include "jstypes.h"
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
|
||||
/*
|
||||
|
@ -55,6 +51,8 @@
|
|||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "jspubtd.h"
|
||||
#include "jstypes.h"
|
||||
#include "jsutil.h"
|
||||
#include "jsstdint.h"
|
||||
#include "jscntxt.h"
|
||||
|
@ -765,27 +763,4 @@ js_IsRuntimeLocked(JSRuntime *rt)
|
|||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
static PRStatus
|
||||
CallOnce(void *func)
|
||||
{
|
||||
JSInitCallback init = JS_DATA_TO_FUNC_PTR(JSInitCallback, func);
|
||||
return init() ? PR_FAILURE : PR_SUCCESS;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_CallOnce(JSCallOnceType *once, JSInitCallback func)
|
||||
{
|
||||
return PR_CallOnceWithArg(once, CallOnce, JS_FUNC_TO_DATA_PTR(void *, func)) == PR_SUCCESS;
|
||||
}
|
||||
#else /* JS_THREADSAFE */
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_CallOnce(JSCallOnceType *once, JSInitCallback func)
|
||||
{
|
||||
if (!*once) {
|
||||
*once = true;
|
||||
return func();
|
||||
} else {
|
||||
return JS_TRUE;
|
||||
}
|
||||
}
|
||||
#endif /* JS_THREADSAFE */
|
||||
|
|
Загрузка…
Ссылка в новой задаче