gtk: Add thread-queue/dequeue-no-hang!, rm peek-until, fix -no-hang.
authorMatt Birkholz <matt@birkholz.chandler.az.us>
Fri, 5 Apr 2013 17:03:45 +0000 (10:03 -0700)
committerMatt Birkholz <matt@birkholz.chandler.az.us>
Fri, 5 Apr 2013 17:03:45 +0000 (10:03 -0700)
Fix when-non-empty-before, which did not append! to waiting-dequeuers,
and thus would only time out.

Not exporting peek-until.  Its TIME argument is... weird -- not
universal.  Swat can import it.

src/gtk/gtk.pkg
src/runtime/runtime.pkg
src/runtime/thread-queue.scm

index da32ea10d7d02ced4bc79be8dbf61fe329e27709..402def6438315cf2abce1239b9d031ffc81ac797 100644 (file)
@@ -379,6 +379,8 @@ USA.
 (define-package (gtk swat)
   (parent (gtk))
   (files "swat")
+  (import (runtime thread-queue)
+         thread-queue/peek-until)
   (import (gtk gtk-widget)
          gtk-widget-destroy-callback)
   (import (gtk fix-layout)
index 78369822bd1858b09d92d0f5fe9ff3e2580160ef..d95720a72c373462162fe4f89bf334f45f2162af 100644 (file)
@@ -577,9 +577,9 @@ USA.
          thread-queue/queue-no-hang!
          thread-queue/push!
          thread-queue/dequeue!
-         thread-queue/peek-no-hang
-         thread-queue/peek-until
-         thread-queue/peek))
+         thread-queue/dequeue-no-hang!
+         thread-queue/peek
+         thread-queue/peek-no-hang))
 
 (define-package (runtime simple-file-ops)
   (files "sfile")
index fcbae0b3a75ceb42c859e89f65e71d2de13a503b..d909974eb087e5d611036c777ac208002e966fbd 100644 (file)
@@ -117,15 +117,15 @@ USA.
            #f)
        (%queue! queue item))))
 
-(define (thread-queue/dequeue-no-hang queue msec)
-  (guarantee-thread-queue queue 'thread-queue/dequeue-no-hang)
-  (guarantee-non-negative-fixnum msec 'thread-queue/dequeue-no-hang)
-  (thread-queue/dequeue-until
+(define (thread-queue/dequeue-no-hang! queue msec)
+  (guarantee-thread-queue queue 'thread-queue/dequeue-no-hang!)
+  (guarantee-non-negative-fixnum msec 'thread-queue/dequeue-no-hang!)
+  (thread-queue/dequeue-until!
    queue (+ (real-time-clock) (internal-time/seconds->ticks (/ msec 1000)))))
 
-(define (thread-queue/dequeue-until queue time)
-  (guarantee-thread-queue queue 'thread-queue/dequeue-until)
-  (guarantee-integer time 'thread-queue/dequeue-until)
+(define (thread-queue/dequeue-until! queue time)
+  (guarantee-thread-queue queue 'thread-queue/dequeue-until!)
+  (guarantee-integer time 'thread-queue/dequeue-until!)
   (when-non-empty-before time queue %dequeue!))
 
 (declare (integrate-operator when-non-empty-before))
@@ -139,6 +139,9 @@ USA.
             (if (<= time now)
                 #f
                 (begin
+                  (set-%thread-queue/waiting-dequeuers!
+                   queue (append! (%thread-queue/waiting-dequeuers queue)
+                                  (list (current-thread))))
                   (register-timer-event (- time now) (lambda () unspecific))
                   (suspend-current-thread)
                   (loop)))))))))