[gjs/wip/ptomato/mozjs45prep: 2/5] context: Use GThread to determine owner thread



commit 4488eadd1380fb663b5d299b14debd6559ffc44b
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.)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781429

 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]