Let thread-uid->thread invoke the GC if it encounters multiple threads with the same uid.
This commit is contained in:
parent
143d96954b
commit
1ed75d8531
|
@ -108,14 +108,31 @@
|
|||
; by rts/channel-port.scm to when forcibly unlocking one of the REPL's ports.
|
||||
|
||||
(define (thread-uid->thread uid)
|
||||
(let ((matching-threads (threads-with-uid uid)))
|
||||
(cond ((null? matching-threads) #f)
|
||||
((null? (cdr matching-threads))
|
||||
(car matching-threads))
|
||||
(else (set! matching-threads #f)
|
||||
((structure-ref primitives collect))
|
||||
(let ((new-matching-threads (threads-with-uid uid)))
|
||||
(cond ((null? new-matching-threads) #f)
|
||||
((null? (cdr new-matching-threads))
|
||||
(car new-matching-threads))
|
||||
(else (debug-message "duplicate thread uid"
|
||||
new-matching-threads)
|
||||
(car new-matching-threads))))))))
|
||||
|
||||
(define (threads-with-uid uid)
|
||||
(let ((threads (all-threads)))
|
||||
(let loop ((i 0))
|
||||
(cond ((= i (vector-length threads))
|
||||
#f)
|
||||
'())
|
||||
((= uid (thread-uid (vector-ref threads i)))
|
||||
(vector-ref threads i))
|
||||
(else
|
||||
(loop (+ i 1)))))))
|
||||
(cons (vector-ref threads i) (loop (+ i 1))))
|
||||
(else
|
||||
(loop (+ i 1)))))))
|
||||
|
||||
|
||||
|
||||
(define (all-threads)
|
||||
((structure-ref primitives find-all-records) :thread))
|
||||
|
|
Loading…
Reference in New Issue