iv_timer(3)
β¨ iv_timer β the ivykis programmer's manual, but make it cute β¨
okay bestie, welcome to iv_timer(3) π this is the page where we learn how ivykis does timers β the little clock gremlins that go off when the system clock says it's time. no cap.
πΈ NAME πΈ
iv_timer_register, iv_timer_unregister, iv_timer_registered β deal with ivykis timers π
π¦ SYNOPSIS π¦
#include <iv.h>
struct iv_timer {
struct timespec expires;
void *cookie;
void (*handler)(void *);
};
void IV_TIMER_INIT(struct iv_timer *timer);
void iv_timer_register(struct iv_timer *timer);
void iv_timer_unregister(struct iv_timer *timer);
int iv_timer_registered(const struct iv_timer *timer);
π DESCRIPTION π
so here's the tea π. iv_timer_register registers a timer with the current thread's ivykis event loop, and iv_timer_unregister unregisters it. iconic duo, fr fr. and iv_timer_registered? that one just looks at a timer and tells you true if it's currently registered with ivykis. vibe check passed β
.
now the main character moment π: when a registered timer becomes 'ready' β which happens when the current system clock value becomes greater than or equal to the timer's ->expires member field β the callback function you put in ->handler gets called. it runs in the thread that the timer was registered in, and it gets ->cookie as its first and sole argument π«Ά.
and then? the timer is transparently unregistered. it unregisters itself, no drama, no follow-up needed. it's giving self-sufficient queen π .
okay so ground rules π:
- the application is allowed to change the
->cookieand->handlermembers at any time β¨ - the application is NOT allowed to change the
->expiresmember while the timer is registered π«
bestie this one matters. ->expires stays put while registered. don't touch it. i'm serious. π
more rules, because of course there are π:
- a given
struct iv_timercan only be registered in one thread at a time - a timer can only be unregistered in the thread that it was registered from β no cross-thread shenanigans, bestie π
and the best part? there is no limit on the number of timers registered at once π register a thousand. register a million. slay β
want actual programming examples? go see iv_examples(3) π§
π SEE ALSO π
k byeeee, go write some timers bestie πβ¨π¦πΈ
this page came from ivykis, dated 2010-08-15, and lives at iv_timer(3) β mwah, periodt π
π¦ where this page comes from
- alpine 3.22: ivykis-doc 0.43.2-r0 Β· LGPL-2.1-or-later
- alpine 3.23: ivykis-doc 0.43.2-r0 Β· LGPL-2.1-or-later
- alpine 3.24: ivykis-doc 0.43.2-r0 Β· LGPL-2.1-or-later
- debian bookworm: libivykis-dev 0.42.4-1
- debian trixie: libivykis-dev 0.43.2-1+b1
- epel 10: ivykis-devel 0.43.2-2.el10_0 Β· LicenseRef-Callaway-LGPLv2+
- epel 9: ivykis-devel 0.42.4-7.el9 Β· LGPLv2+
- fedora 43: ivykis-devel 0.43.2-4.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: ivykis-devel 0.43.2-4.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: ivykis-devel 0.43.2-5.fc44 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: ivykis-devel 0.43.2-5.fc44 Β· LicenseRef-Callaway-LGPLv2+
- nixpkgs unstable: libivykis 0.43.2
- opensuse-leap 16.0: ivykis-devel 0.43-bp160.1.12 Β· LGPL-2.1-only
- opensuse-leap 16.0: ivykis-devel 0.43-bp160.1.12 Β· LGPL-2.1-only
- opensuse-leap 16.0: ivykis-devel 0.43-bp160.1.12 Β· LGPL-2.1-only
- opensuse-leap 16.0: ivykis-devel 0.43-bp160.1.12 Β· LGPL-2.1-only
- ubuntu jammy: libivykis-dev 0.42.4-1
- ubuntu noble: libivykis-dev 0.43-1build1
- ubuntu questing: libivykis-dev 0.43.2-1
- ubuntu resolute: libivykis-dev 0.43.2-1build1
- ubuntu stonking: libivykis-dev 0.43.2-1build1
- Copyright (C) 2003, 2010 Lennert Buytenhek
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms