Skip to content

Commit

Permalink
timer-wheel: Add ‘timer-wheel-remove!’.
Browse files Browse the repository at this point in the history
* fibers/timer-wheel.scm (timer-wheel-remove!): New procedure.
  • Loading branch information
civodul committed Nov 10, 2024
1 parent cbb433f commit de52e08
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fibers/timer-wheel.scm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#:use-module (ice-9 format)
#:export (make-timer-wheel
timer-wheel-add!
timer-wheel-remove!
timer-wheel-next-entry-time
timer-wheel-next-tick-start
timer-wheel-next-tick-end
Expand Down Expand Up @@ -141,6 +142,18 @@
(else
(timer-wheel-add! (or outer (add-outer-wheel! wheel)) t obj)))))))

(define (timer-wheel-remove! wheel entry)
"Remove @var{entry}, a timer entry as returned by @code{timer-wheel-add!},
from @var{wheel}."
(match entry
(($ <timer-entry> prev next)
(when prev
(set-timer-entry-next! prev next)
(set-timer-entry-prev! entry #f))
(when next
(set-timer-entry-prev! next prev)
(set-timer-entry-next! entry #f)))))

(define (timer-wheel-next-entry-time wheel)
(define (slot-min-time head)
(let lp ((entry (timer-entry-next head)) (min #f))
Expand Down

0 comments on commit de52e08

Please sign in to comment.