Commits

Moritz Heidkamp committed 066ab34

fix forking empty channels

Comments (0)

Files changed (1)

        (channel-empty? channel)))
 
 (define (channel-fork! channel)
-  (let ((fork  (make-channel))
-        (mutex (channel-mutex channel)))
+  (let ((mutex (channel-mutex channel)))
     (mutex-lock! mutex)
-    (push! (make-weak-locative fork) (channel-forks channel))
-    (apply channel-enqueue! fork (channel-messages channel))
-    (mutex-unlock! mutex)
-    fork))
+    (let ((fork (apply make-channel (channel-messages channel))))
+      (push! (make-weak-locative fork) (channel-forks channel))
+      (mutex-unlock! mutex)
+      fork)))
 
 (define (on-channel-close channel thunk)
   (if (channel-closed? channel)