[gjs/wip/ptomato/mozjs38: 6/32] object: split out clear pending toggles



commit 6319c101db890c6847a4e601fd644ab3a16f02da
Author: Philip Chimento <philip endlessm com>
Date:   Thu Feb 2 16:16:01 2017 -0800

    object: split out clear pending toggles
    
    FIXME: Maybe this should be squashed into the GjsMaybeOwned patch.
    
    We separate out the two steps in gjs_object_prepare_shutdown(): handling
    any pending toggle references, and releasing all the native objects. When
    switching to GjsContext destroy notifications with GjsMaybeOwned, we'll
    need to handle the idle toggles before doing a garbage collection.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776966

 gi/object.cpp |   16 +++++++++++-----
 gi/object.h   |    2 ++
 2 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 0248d46..aa33ad2 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1240,6 +1240,15 @@ release_native_object (ObjectInstance *priv)
  * pending toggle references.
  */
 void
+gjs_object_clear_toggles(void)
+{
+    while (g_main_context_pending(NULL) &&
+           g_atomic_int_get(&pending_idle_toggles) > 0) {
+        g_main_context_iteration(NULL, false);
+    }
+}
+
+void
 gjs_object_prepare_shutdown (JSContext *context)
 {
     JSObject *keep_alive = gjs_keep_alive_get_global_if_exists (context);
@@ -1251,13 +1260,10 @@ gjs_object_prepare_shutdown (JSContext *context)
         return;
 
     /* First, get rid of anything left over on the main context */
-    while (g_main_context_pending(NULL) &&
-           g_atomic_int_get(&pending_idle_toggles) > 0) {
-        g_main_context_iteration(NULL, false);
-    }
+    gjs_object_clear_toggles();
 
     /* Now, we iterate over all of the objects, breaking the JS <-> C
-     * associaton.  We avoid the potential recursion implied in:
+     * association.  We avoid the potential recursion implied in:
      *   toggle ref removal -> gobj dispose -> toggle ref notify
      * by simply ignoring toggle ref notifications during this process.
      */
diff --git a/gi/object.h b/gi/object.h
index 92744e1..d37d1df 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -58,6 +58,8 @@ bool      gjs_typecheck_is_object(JSContext       *context,
 
 void      gjs_object_prepare_shutdown   (JSContext     *context);
 
+void gjs_object_clear_toggles(void);
+
 void gjs_object_define_static_methods(JSContext       *context,
                                       JS::HandleObject constructor,
                                       GType            gtype,


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