No matching definitions.

tur/timer

stdlib/timer.tur

Timer API backed by a min-heap timer wheel.

Since: Phase T24

defopaque

TimerId

(TimerId)
defn

timer-set

(timer-set [ms : int callback ptr<void> arg ptr<void>] :)

schedule a one-shot callback after a delay.

msdelay in milliseconds before the callback fires (:int).
callbacka :ptr<void> to the function to invoke; signature void(*)(void*).
argopaque :ptr<void> passed to callback when it fires.

A TimerId that can be passed to timer-cancel to abort the timer before it fires.

(timer-set 500 my-cb my-arg)  ; => TimerId  (fires in 500 ms)

Since: Phase T24

defn

timer-cancel

(timer-cancel [id : TimerId] :)

cancel a previously scheduled timer.

idthe timer ID returned by timer-set.
(timer-cancel 3)  ; cancel timer with ID 3

Since: Phase T24

defn

timer-sleep

(timer-sleep [ms : int] :)

park the current fiber for a given number of milliseconds.

msnumber of milliseconds to sleep (:int); no-op if <= 0.
(timer-sleep 1000)  ; pause the current fiber for 1 second

Since: Phase T24