Bug 677079 - Part a: Move AutoLockGC to jsfriendapi.h; r=igor

This commit is contained in:
Ms2ger 2012-01-15 09:13:07 +01:00
Родитель 4a62e49ffb
Коммит f085e09f42
3 изменённых файлов: 58 добавлений и 32 удалений

Просмотреть файл

@ -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 */
/*