Make FLUSH-ALL-PORTS blocking so FORK will do something more sensible.

Previously,

(begin
  (display "ha!") (newline)
  (fork (lambda ()
	  'foo)))

would print "ha!" twice because FLUSH-ALL-PORTS would not finish
before the actual FORK.
This commit is contained in:
sperber 2002-02-25 20:29:15 +00:00
parent 9a06464234
commit 380fee6612
1 changed files with 22 additions and 1 deletions

View File

@ -545,9 +545,30 @@
(cond ((null? thunks)
#f)
(else
(for-each (structure-ref threads spawn) thunks)
(let loop ((threads
(map spawn-thread thunks))
(new-threads '()))
(cond
((not (null? threads))
(if ((structure-ref threads-internal thread-continuation)
(car threads))
(loop (cdr threads)
(cons (car threads) new-threads))
(loop (cdr threads) new-threads)))
((not (null? new-threads))
(loop new-threads '()))))
#t))))
(define (spawn-thread thunk)
(let ((placeholder (make-placeholder)))
(spawn
(lambda ()
(placeholder-set!
placeholder
((structure-ref threads-internal current-thread)))
(thunk)))
(placeholder-value placeholder)))
;;; Extend R4RS i/o ops to handle file descriptors.
;;; -----------------------------------------------