iv_task(3)
π iv_task β bestie edition π
okay so this is iv_task(3), straight out of the ivykis programmer's manual, and it's literally all about dealing with ivykis tasks. three little functions, one cute struct, infinite possibilities. let's get into it π
β¨ NAME β¨
iv_task_register, iv_task_unregister, iv_task_registered β the trio that handles all your ivykis task business π
πΈ SYNOPSIS πΈ
#include <iv.h>
struct iv_task {
void *cookie;
void (*handler)(void *);
};
void IV_TASK_INIT(struct iv_task *task);
void iv_task_register(struct iv_task *task);
void iv_task_unregister(struct iv_task *task);
int iv_task_registered(const struct iv_task *task);
π¦ DESCRIPTION π¦
okay so picture this. iv_task_register and iv_task_unregister do exactly what their names say β they register and unregister a task with the current thread's ivykis event loop. no cap. and iv_task_registered? she looks at a task and tells you true if that task is currently registered with ivykis. a queen who just knows things π
now here's the vibe: a task is basically a timer, except with an immediate timeout. so it's a timer that's like "bestie i'm ready NOW." β¨
when you register a task, unless you unregister it again first, the callback function you put in ->handler is guaranteed to be called exactly once, in the thread that the task was registered in. when does it fire? some time after control returns to the ivykis main loop, but before ivykis will sleep for more events. and it gets ->cookie as its first and sole argument. that's it, that's the whole gift π
and the moment that callback runs, the task is transparently unregistered. no cleanup, no drama, she just goes. periodt.
so why would you even use tasks? mainly for scheduling code for execution in situations where it's just not appropriate to directly run that code in the calling context. classic example: the current context might itself be running as a callback function, and the caller expects certain conditions to remain invariant after the callback completes. so you can't just yolo into that code right there. you schedule it. main character energy, but respectful π
the application is allowed to change the ->cookie and ->handler members at any time. go off, glow up your struct whenever π«Ά
β οΈ okay important rules, bestie, don't skip these: - a given struct iv_task can only be registered in one thread at a time - a task can only be unregistered in the thread that it was registered from
and the good news? there is no limit on the number of tasks registered at once. register a thousand. register a million. the universe says yes π₯
if you want actual programming examples (and honestly, you do), go peek at iv_examples(3). it's giving tutorial, it's giving inspiration π
π SEE ALSO π
and that's the whole page, babe π this one's from ivykis, dated 2010-08-15 β a classic, an icon, a legend, and she still slays. go forth and register your tasks responsibly β¨ππ¦
π¦ 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