Include dependency graph for timer_list.c:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "3" [label="stdbool.h" tooltip="stdbool.h"]
    "4" [label="stdint.h" tooltip="stdint.h"]
    "1" [label="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/timer_list.c" tooltip="/home/runner/work/AtomVM/AtomVM/src/libAtomVM/timer_list.c" fillcolor="#BFBFBF"]
    "2" [label="timer_list.h" tooltip="timer_list.h"]
    "5" [label="list.h" tooltip="list.h"]
    "1" -> "2" [dir=forward tooltip="include"]
    "2" -> "3" [dir=forward tooltip="include"]
    "2" -> "4" [dir=forward tooltip="include"]
    "2" -> "5" [dir=forward tooltip="include"]


void timer_list_next(struct TimerList *tw, uint64_t now, timer_list_callback_t cb)

process the timer wheel, calling cb for every item that should be fired (for which expiry_time <= now).

The current algorithm is very basic. Under heavy load, two processes scheduled for different timers might be triggered (same seems to be true with BEAM). The only optimization is the next time is saved so the function doesn’t run every timer on every call.

  • tw – the timer wheel

  • now – the current monotonic date

  • cb – the callback