зеркало из https://github.com/mozilla/gecko-dev.git
Bug 677079 - Part a: Move AutoLockGC to jsfriendapi.h; r=igor
This commit is contained in:
Родитель
4a62e49ffb
Коммит
f085e09f42
|
@ -1617,38 +1617,6 @@ class AutoXMLRooter : private AutoGCRooter {
|
|||
};
|
||||
#endif /* JS_HAS_XML_SUPPORT */
|
||||
|
||||
class AutoLockGC {
|
||||
public:
|
||||
explicit AutoLockGC(JSRuntime *rt = NULL
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: runtime(rt)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
if (rt)
|
||||
JS_LOCK_GC(rt);
|
||||
}
|
||||
|
||||
bool locked() const {
|
||||
return !!runtime;
|
||||
}
|
||||
|
||||
void lock(JSRuntime *rt) {
|
||||
JS_ASSERT(rt);
|
||||
JS_ASSERT(!runtime);
|
||||
runtime = rt;
|
||||
JS_LOCK_GC(rt);
|
||||
}
|
||||
|
||||
~AutoLockGC() {
|
||||
if (runtime)
|
||||
JS_UNLOCK_GC(runtime);
|
||||
}
|
||||
|
||||
private:
|
||||
JSRuntime *runtime;
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoUnlockGC {
|
||||
private:
|
||||
JSRuntime *rt;
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
#include "jswrapper.h"
|
||||
#include "jsweakmap.h"
|
||||
|
||||
#include "mozilla/GuardObjects.h"
|
||||
|
||||
#include "jsobjinlines.h"
|
||||
|
||||
using namespace js;
|
||||
|
@ -467,6 +469,29 @@ js::DumpHeapComplete(JSContext *cx, FILE *fp)
|
|||
|
||||
namespace js {
|
||||
|
||||
/* static */ void
|
||||
AutoLockGC::LockGC(JSRuntime *rt)
|
||||
{
|
||||
JS_ASSERT(rt);
|
||||
JS_LOCK_GC(rt);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
AutoLockGC::UnlockGC(JSRuntime *rt)
|
||||
{
|
||||
JS_ASSERT(rt);
|
||||
JS_UNLOCK_GC(rt);
|
||||
}
|
||||
|
||||
void
|
||||
AutoLockGC::lock(JSRuntime *rt)
|
||||
{
|
||||
JS_ASSERT(rt);
|
||||
JS_ASSERT(!runtime);
|
||||
runtime = rt;
|
||||
JS_LOCK_GC(rt);
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
JSThread *
|
||||
GetContextThread(const JSContext *cx)
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
#include "jspubtd.h"
|
||||
#include "jsprvtd.h"
|
||||
|
||||
#include "mozilla/GuardObjects.h"
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
|
@ -453,6 +455,37 @@ JS_FRIEND_API(JSThread *)
|
|||
GetContextThread(const JSContext *cx);
|
||||
#endif
|
||||
|
||||
class JS_FRIEND_API(AutoLockGC)
|
||||
{
|
||||
public:
|
||||
explicit AutoLockGC(JSRuntime *rt = NULL
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: runtime(rt)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
if (rt)
|
||||
LockGC(rt);
|
||||
}
|
||||
|
||||
~AutoLockGC()
|
||||
{
|
||||
if (runtime)
|
||||
UnlockGC(runtime);
|
||||
}
|
||||
|
||||
bool locked() const {
|
||||
return !!runtime;
|
||||
}
|
||||
void lock(JSRuntime *rt);
|
||||
|
||||
private:
|
||||
static void LockGC(JSRuntime *rt);
|
||||
static void UnlockGC(JSRuntime *rt);
|
||||
|
||||
JSRuntime *runtime;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче