cs & thread: avoid accumulating post-atomic callbacks
Only one instance of each callback is needed. Allowing them to pile up is inefficient, and possibly it can trigger a reaction that causes even more to pile up.
This commit is contained in:
parent
b86ca89102
commit
ec72f5df45
|
@ -105,7 +105,14 @@
|
|||
;; no race with the scheduler
|
||||
(define (add-end-atomic-callback! cb)
|
||||
(host:disable-interrupts)
|
||||
(end-atomic-callback (cons cb (end-atomic-callback)))
|
||||
(define all-cbs (end-atomic-callback))
|
||||
(let loop ([cbs all-cbs])
|
||||
(cond
|
||||
[(eq? cbs 0)
|
||||
(end-atomic-callback (cons cb all-cbs))]
|
||||
[else
|
||||
(unless (eq? (car cbs) cb)
|
||||
(loop (cdr cbs)))]))
|
||||
(host:enable-interrupts))
|
||||
|
||||
;; ----------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user