Fixed memory leak.
This commit is contained in:
parent
73b11ef47f
commit
6158e7a964
|
@ -485,7 +485,7 @@
|
|||
(next (make-placeholder))
|
||||
prev)
|
||||
|
||||
(define reaped-proc-tail (make-placeholder))
|
||||
(define reaped-proc-tail (make-reaped-proc (make-weak-pointer #f) 'head))
|
||||
(define reaped-proc-head reaped-proc-tail)
|
||||
(define reaped-proc-push-lock (make-lock))
|
||||
(define reaped-proc-pop-lock (make-lock)) ;;; Zippy sez: pop lock!
|
||||
|
@ -493,22 +493,29 @@
|
|||
(define (push-reaped-proc proc)
|
||||
(obtain-lock reaped-proc-push-lock)
|
||||
(let ((push-me (make-reaped-proc (make-weak-pointer proc) reaped-proc-tail)))
|
||||
(placeholder-set! reaped-proc-tail push-me)
|
||||
; (add-finalizer! proc (lambda ignore (remove-reaped-proc push-me)))
|
||||
(set! reaped-proc-tail (reaped-proc:next push-me)))
|
||||
(placeholder-set! (reaped-proc:next reaped-proc-tail) push-me)
|
||||
(add-finalizer! proc (make-reaped-proc-finalizer push-me))
|
||||
(set! reaped-proc-tail push-me))
|
||||
(release-lock reaped-proc-push-lock))
|
||||
|
||||
(define (make-reaped-proc-finalizer push-me)
|
||||
(lambda ignore
|
||||
(remove-reaped-proc push-me)))
|
||||
|
||||
(define (remove-reaped-proc reaped-proc)
|
||||
(spawn (lambda () ;This is blocking, so should run by itself
|
||||
(placeholder-set! (reaped-proc:prev reaped-proc)
|
||||
(placeholder-value
|
||||
(reaped-proc:next reaped-proc))))
|
||||
"reaped-proc-removing-thread"))
|
||||
(set-reaped-proc:prev
|
||||
(placeholder-value (reaped-proc:next reaped-proc))
|
||||
(reaped-proc:prev reaped-proc))
|
||||
(set-reaped-proc:next
|
||||
(reaped-proc:prev reaped-proc)
|
||||
(reaped-proc:next reaped-proc)))
|
||||
"reaped-proc-removing-thread"))
|
||||
|
||||
(define (pop-reaped-proc)
|
||||
(obtain-lock reaped-proc-pop-lock) ;;; pop lock pop lock pop lock!
|
||||
(let ((pop-me (placeholder-value reaped-proc-head)))
|
||||
(set! reaped-proc-head (reaped-proc:next pop-me))
|
||||
(let ((pop-me (placeholder-value (reaped-proc:next reaped-proc-head))))
|
||||
(set! reaped-proc-head pop-me)
|
||||
(release-lock reaped-proc-pop-lock)
|
||||
(weak-pointer-ref (reaped-proc:proc pop-me))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue