[gjs/wip/ptomato/mozjs45prep: 9/12] context: Use GThread to determine owner thread



commit 8aa3f5506faadd22ae52f93d949d51e2ced9877e
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue May 2 21:02:47 2017 -0700

    context: Use GThread to determine owner thread
    
    The thread facilities are going away in SpiderMonkey 52, so we use GThread
    to determine a context's owner thread in order to be able to check it
    later. (g_thread_self() will still work if GLib didn't create the thread.)

 gjs/context.cpp |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 1d77a39..2b506c2 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -69,7 +69,7 @@ struct _GjsContext {
     JSRuntime *runtime;
     JSContext *context;
     JS::Heap<JSObject*> global;
-    intptr_t owner_thread;
+    GThread *owner_thread;
 
     char *program_name;
 
@@ -487,7 +487,7 @@ gjs_context_constructed(GObject *object)
     js_context->runtime = gjs_runtime_ref();
 
     JS_AbortIfWrongThread(js_context->runtime);
-    js_context->owner_thread = JS_GetCurrentThread();
+    js_context->owner_thread = g_thread_self();
 
     js_context->context = JS_NewContext(js_context->runtime, 8192 /* stack chunk size */);
     if (js_context->context == NULL)
@@ -666,7 +666,7 @@ context_reset_exit(GjsContext *js_context)
 bool
 _gjs_context_get_is_owner_thread(GjsContext *js_context)
 {
-    return js_context->owner_thread == JS_GetCurrentThread();
+    return js_context->owner_thread == g_thread_self();
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]