smp: without-interrupts: x11graph.scm
authorMatt Birkholz <puck@birchwood-abbey.net>
Wed, 11 Mar 2015 00:08:10 +0000 (17:08 -0700)
committerMatt Birkholz <puck@birchwood-abbey.net>
Wed, 11 Mar 2015 00:08:10 +0000 (17:08 -0700)
README.txt
src/runtime/runtime.pkg
src/runtime/x11graph.scm

index a58845be0c4ecf8e419cfbdcf27d886ea8065c19..0777f49a8ce8b82f4f12fa5fda4289dbd0fe22ae 100644 (file)
@@ -1629,5 +1629,10 @@ The hits with accompanying analysis:
        Punted until Win32 can SMP.
 
   x11graph.scm:264:  (without-interrupts
+       Caller: x-graphics/close-display
   x11graph.scm:344:  (without-interrupts
+       Caller: process-event
   x11graph.scm:449:  (without-interrupts
+       Caller: x-graphics/close-window
+
+       Used the display-finalizer's mutex to serialize the callers.
index f014bc266ccf4d60d67131aa6b522aa2c9cd0b37..cfb2169b576581aceb619f3b7a2f012610f1a984 100644 (file)
@@ -3943,6 +3943,9 @@ USA.
     ((unix) "x11graph")
     (else))
   (parent (runtime))
+  (import (runtime gc-finalizer)
+         with-gc-finalizer-locked
+         remove-from-locked-gc-finalizer!)
   (export ()
          create-x-colormap
          create-x-image
index be741ce99a13f1d63877ca0656ee7fbac2affbd2..3b87d391718970598e9cbd01d42ba8ed2df4f40d 100644 (file)
@@ -261,12 +261,14 @@ USA.
            display)))))
 
 (define (x-graphics/close-display display)
-  (without-interrupts
-   (lambda ()
-     (if (x-display/xd display)
-        (begin
-          (remove-all-from-gc-finalizer! (x-display/window-finalizer display))
-          (remove-from-gc-finalizer! display-finalizer display))))))
+  (with-gc-finalizer-locked display-finalizer
+    (lambda ()
+      (if (x-display/xd display)
+         (without-interruption
+          (lambda ()
+            (remove-all-from-gc-finalizer! (x-display/window-finalizer
+                                            display))
+            (remove-from-locked-gc-finalizer! display-finalizer display)))))))
 
 (define (x-graphics/open-display? display)
   (if (x-display/xd display) #t #f))
@@ -341,7 +343,7 @@ USA.
     (with-thread-events-blocked loop)))
 \f
 (define (process-event display event)
-  (without-interrupts
+  (with-gc-finalizer-locked display-finalizer
    (lambda ()
      (let ((window
            (search-gc-finalizer (x-display/window-finalizer display)
@@ -446,7 +448,7 @@ USA.
   (if (x-graphics-device/xw device) #t #f))
 
 (define (x-graphics/close-window device)
-  (without-interrupts
+  (with-gc-finalizer-locked display-finalizer
    (lambda ()
      (close-x-window (graphics-device/descriptor device)))))