+ Fixed small race condition problem in wait. There are still problems
when lots of processes are forked + Added optional name parameter in run-as-long-as
This commit is contained in:
parent
405512e0db
commit
6671ff0e04
|
@ -178,7 +178,8 @@
|
|||
(let ((next-event (next-sigevent event interrupt/chld)))
|
||||
(*sigchld-handler*)
|
||||
(lp next-event))))
|
||||
thunk))
|
||||
thunk
|
||||
'auto-reaping))
|
||||
|
||||
;;; This list contains pids whose proc-obj were gc'd before they died
|
||||
;;; We try to reap them after every gc and maybe on every SIGCHLD
|
||||
|
@ -291,9 +292,9 @@
|
|||
(release-lock wait-lock)
|
||||
; we have to block and hence use the event system
|
||||
(let lp ((pre-event pre-event))
|
||||
(let ((event (next-sigevent pre-event interrupt/chld)))
|
||||
(cond ((wait proc (bitwise-ior flags wait/poll)) => win)
|
||||
(else (lp event))))))
|
||||
(else
|
||||
(lp (next-sigevent pre-event interrupt/chld))))))
|
||||
|
||||
((eq? wait/poll (bitwise-and flags wait/poll))
|
||||
(cond ((really-wait (proc:pid proc) flags) => win)
|
||||
|
|
|
@ -188,7 +188,7 @@
|
|||
(structure-ref threads-internal event-type)
|
||||
interrupt)
|
||||
(enum interrupt keyboard))))))
|
||||
(run-as-long-as deliver-interrupts thunk))
|
||||
(run-as-long-as deliver-interrupts thunk 'deliver-interrupts))
|
||||
|
||||
(define (deliver-interrupts)
|
||||
(let lp ((last ((structure-ref sigevents most-recent-sigevent))))
|
||||
|
|
|
@ -273,11 +273,12 @@
|
|||
; This is *extremly* low level
|
||||
; Don't use unless you know what you are doing
|
||||
|
||||
(define (run-as-long-as thunk1 thunk2)
|
||||
(define (run-as-long-as thunk1 thunk2 . name)
|
||||
(let ((thread (make-placeholder)))
|
||||
(spawn (lambda ()
|
||||
(apply spawn (lambda ()
|
||||
(placeholder-set! thread (current-thread))
|
||||
(thunk1)))
|
||||
(thunk1))
|
||||
name)
|
||||
(dynamic-wind
|
||||
(lambda () #t)
|
||||
thunk2
|
||||
|
|
Loading…
Reference in New Issue