If you find that this library lacks some feature you need, or you have a suggestion for improving it, please don’t hesitate to get in touch with me!
This library provides utilities for managing a heap of timeouts when programming in an event-driven style with sync.
All the functionality below can be accessed with a single require:
|(require (planet tonyg/timers:1:=0))|
tm : timer-manager? deadline : nonnegative-number? handler : (-> any?)
tm : timer-manager? delta-msec : number? handler : (-> any?)
(fire-single-timer-evt tm k-fired k-not-fired) → evt? tm : timer-manager? k-fired : (->* () #:rest any? any?) k-not-fired : (-> any?)
(fire-single-timer tm k-fired k-not-fired) → any?
tm : timer-manager? k-fired : (->* () #:rest any? any?) k-not-fired : (-> any?)
(struct timer-manager (heap) #:extra-constructor-name make-timer-manager #:transparent) heap : heap?
(struct pending-timer (deadline handler cancelled?) #:extra-constructor-name make-pending-timer #:transparent) deadline : nonnegative-number? handler : (-> any?) cancelled? : boolean?
pending-timer-handler is the timer callback. It will be called with no arguments, and may yield any number of values. The values are ignored if either fire-timers or fire-timers-evt is used to trigger the firing of the timer, and are used if either fire-single-timer or fire-single-timer-evt fire the timer.
pending-timer-cancelled? indicates whether this timer has been cancelled. A cancelled timer’s callback will never be called; it is as if it were never registered.