JS_DestroyRuntime nukes all contexts; add JS_G/SetRuntimePrivate (r=tlundeen@webcrossing.com).

This commit is contained in:
brendan%mozilla.org 2000-05-17 06:23:03 +00:00
parent e9e143bc69
commit 7dd0a4f6c4
3 changed files with 27 additions and 1 deletions

View File

@ -631,7 +631,7 @@ JS_NewRuntime(uint32 maxbytes)
rt->requestDone = JS_NEW_CONDVAR(rt->gcLock);
if (!rt->requestDone)
goto bad;
js_SetupLocks(20,20); /* this is asymmetric with JS_ShutDown. */
js_SetupLocks(20,20); /* this is asymmetric with JS_ShutDown. */
rt->rtLock = JS_NEW_LOCK();
rt->stateChange = JS_NEW_CONDVAR(rt->rtLock);
#endif
@ -649,6 +649,11 @@ bad:
JS_PUBLIC_API(void)
JS_DestroyRuntime(JSRuntime *rt)
{
JSContext *cx, *iter;
iter = NULL;
while ((cx = js_ContextIterator(rt, &iter)) != NULL)
js_DestroyContext(cx, JS_NO_GC);
js_FinishGC(rt);
#ifdef JS_THREADSAFE
if (rt->gcLock)
@ -672,6 +677,18 @@ JS_ShutDown(void)
#endif
}
JS_PUBLIC_API(void *)
JS_GetRuntimePrivate(JSRuntime *rt)
{
return rt->data;
}
JS_PUBLIC_API(void)
JS_SetRuntimePrivate(JSRuntime *rt, void *data)
{
rt->data = data;
}
#ifdef JS_THREADSAFE
JS_PUBLIC_API(void)

View File

@ -334,6 +334,12 @@ JS_DestroyRuntime(JSRuntime *rt);
extern JS_PUBLIC_API(void)
JS_ShutDown(void);
JS_PUBLIC_API(void *)
JS_GetRuntimePrivate(JSRuntime *rt);
JS_PUBLIC_API(void)
JS_SetRuntimePrivate(JSRuntime *rt, void *data);
#ifdef JS_THREADSAFE
extern JS_PUBLIC_API(void)

View File

@ -134,6 +134,9 @@ struct JSRuntime {
/* XXX must come after JSCLists or MSVC alignment bug bites empty lists */
JSPropertyCache propertyCache;
/* Client opaque pointer */
void *data;
#ifdef JS_THREADSAFE
/* These combine to interlock the GC and new requests. */
PRLock *gcLock;