iv_event(3)
π iv_event(3) β the ivykis programmer's manual, but make it cute π
okay bestie, so this is iv_event(3) from the ivykis programmer's manual, and it's literally the whole guide to cross-thread event notification. no cap. let's get into it π¦
β¨ NAME β¨
IV_EVENT_INIT, iv_event_register, iv_event_unregister, iv_event_post β manage ivykis objects for event notification π
πΈ SYNOPSIS πΈ
#include <iv_event.h>
struct iv_event {
void *cookie;
void (*handler)(void *);
};
int IV_EVENT_INIT(struct iv_event *this);
int iv_event_register(struct iv_event *this);
void iv_event_unregister(struct iv_event *this);
void iv_event_post(struct iv_event *this);
π DESCRIPTION π
iv_event is the way to deliver events to ivykis(3) recipients across thread boundaries. it's giving inter-thread communication, it's giving "my other thread has something to tell you" π
so here's the whole vibe. the thread that's supposed to receive the event β the intended recipient β does this:
- calls
IV_EVENT_INITon astruct iv_eventobject - fills in
->cookieand->handler - calls
iv_event_registeron the object
that's the setup, and it ate, no crumbs π
now, to actually generate an event? call iv_event_post on the struct iv_event object you already initialized. what happens next is the moment β¨: the callback you specified in ->handler gets called in the thread that the struct iv_event object was registered in, and its sole argument is ->cookie. periodt.
to deinitialize a struct iv_event object, call iv_event_unregister β and listen, this has to happen from the same thread that iv_event_register was called from on that object. like, same thread. iykyk π
but here's the fun part, and it's lowkey iconic:
- it is permitted to unregister a
struct iv_eventobject from any ivykis callback function, as long as you're in the thread it was registered in β including from a callback function that was triggered by this very object π₯ - and it is permitted to free the memory of an unregistered object from its own callback function. main character energy honestly π
okay so where can you call iv_event_post from? let's vibe check that:
- β
from the same thread that
iv_event_registerwas called from - β from a different thread, as long as it's within the same process
- β can not be called from a different process
- β can not be called from signal handlers
π¨ if you need that functionality, bestie, go look at iv_event_raw(3). it's the one for you.
and the tea on how it works under the hood π«: internally, iv_event is implemented as a wrapper around iv_event_raw(3), and it multiplexes multiple struct iv_event objects over per-thread struct iv_event_raw objects β all so it can save file descriptors and kernel resources. efficient queen π
π SEE ALSO π
that's the whole page, bestie, you're so welcome π«Ά ivykis, dated 2010-09-03 β yeah she's an oldie but she's a classic, and she's still slaying β¨ππ
π¦ 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) 2010 Lennert Buytenhek
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms