glib: Residual fixes. Less integration for easier debugging.
authorMatt Birkholz <matt@birchwood-abbey.net>
Sun, 11 Mar 2018 17:09:53 +0000 (10:09 -0700)
committerMatt Birkholz <matt@birchwood-abbey.net>
Sun, 11 Mar 2018 17:09:53 +0000 (10:09 -0700)
src/glib/glib.pkg
src/glib/glib.scm

index c320bb1d726ff10b4395ee189a2edcb0626fb6eb..0776325be37de2ea7b07d090e3c86bfdb6a8e0af 100644 (file)
@@ -114,8 +114,9 @@ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
   (export ()
          stop-glib-thread)
   (import (glib)
-         glib-mutex                    ;exposed by with-glib-lock, run-glib,...
+         glib-mutex                    ;exposed by integrated with-glib-lock
          with-glib-lock
+         assert-glib-locked
          run-glib-cleanups
          run-glib-daemons)
   (import (glib main)
index 0adc5a85be6d6642c4c2cafa4ffd0b6b6de33e08..6dd3719820a587221cc0a36ca8cb0a0894f08e86 100644 (file)
@@ -122,28 +122,20 @@ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 (define (reset-glib-mutex!)
   (set! glib-mutex (make-thread-mutex)))
 
-(define-integrable (with-glib-lock thunk)
+(define (with-glib-lock thunk)
   (with-thread-mutex-lock glib-mutex thunk))
 
-(define-integrable-operator (without-glib-lock thunk)
-  ;; Temporarily use thread-mutex-owner to (try to) avoid signaling an
-  ;; error when glib is not locked.  This should actually avoid the
-  ;; error in single threaded worlds.
-  (let ((owner (thread-mutex-owner glib-mutex)))
-    (if (eq? #f owner)
-       (begin
-         (outf-error ";glib already unlocked\n")
-         (thunk)
-         ;; Lock it *now*?
-         )
-       (without-thread-mutex-lock glib-mutex thunk))))
+(define (without-glib-lock thunk)
+  (without-thread-mutex-lock glib-mutex thunk))
 
-(define-integrable (assert-glib-locked operator)
+#;(define-integrable (assert-glib-locked operator) #f)
+(define (assert-glib-locked operator)
   ;; Useful at least when debugging single threaded worlds.
   (if (not (eq? (current-thread) (thread-mutex-owner glib-mutex)))
       (outf-error ";glib not locked: "operator"\n")))
 
-(define-integrable (assert-without-interruption operator)
+#;(define-integrable (assert-without-interruption operator) #f)
+(define (assert-without-interruption operator)
   (if (not (get-thread-event-block))
       (outf-error ";not without-interruption: "operator"\n")))
 
@@ -167,6 +159,7 @@ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
              (loop next prev))))))
 
 (define (run-glib-daemons)
+  (assert-glib-locked 'run-glib-daemons)
   (with-glib-error-handler "the secondary GC daemons"
                           trigger-secondary-gc-daemons!))
 
@@ -193,7 +186,8 @@ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
     weak-pair))
 
 (define (execute-glib-cleanup object)
-  (assert-glib-locked 'execute-glib-cleanup) ; and without-interruption
+  (assert-without-interruption 'execute-glib-cleanup)
+  (assert-glib-locked 'execute-glib-cleanup)
   (let ((entry (weak-assq object glib-cleanups)))
     (if entry
        (begin