1. Moritz Heidkamp
  2. channel


Moritz Heidkamp  committed f77fee3

when `channel-receive!` is called asynchronously return #t if the channel is not empty, i.e. the receivers are executed immediately, otherwise return #f

  • Participants
  • Parent commits e77dc35
  • Branches master

Comments (0)

Files changed (2)

File channel.scm

View file
  • Ignore whitespace
               (queue-add-list! rqueue procs)
-              (mutex-unlock! mutex)))
+              (mutex-unlock! mutex)
+              #f))
         (let ((message (queue-remove! queue)))
           (if sync?
                 (call-each message procs)
-                (mutex-unlock! mutex)))))))
+                (mutex-unlock! mutex)
+                #t))))))
 (define (channel-close! channel)
   (set! (channel-closed? channel) #t)

File tests/run.scm

View file
  • Ignore whitespace
   (define c (make-channel))
   (channel-enqueue! c 1)
   (define results (make-receiver))
-  (channel-receive! c results)
+  (test-assert (channel-receive! c results))
   (test (results) '(1))
+  (test-assert (not (channel-receive! c results)))
+  (channel-enqueue! c 2)
+  (test (results) '(1 2))
   (define results (make-receiver))
   (channel-enqueue! c 1 2)