iom_add(3)

πŸ“¦
version 0.34 Β· 2 versions
, in alpine 3.24, nixos 26.05, nixpkgs unstable, ubuntu resolute, ubuntu stonking

πŸ’– iom_add(3) πŸ’–

okay so bestie, welcome to iom_add from the Library Functions Manual πŸŽ€ this is the libowfat girlie that puts an event on your I/O multiplexer's to-do list, and honestly? she's iconic for it ✨


🌸 NAME 🌸

iom_add β€” add event to I/O multiplexer 🫢


✨ SYNTAX ✨

#include <libowfat/io.h>

int iom_add(iomux_t* c, int64 fd, unsigned int events);

like look at that signature. so clean. so slay. πŸ’…


πŸ’… DESCRIPTION πŸ’…

so basically, iom_add adds an event you are interested in to an I/O multiplexer. that's the whole vibe. you're telling the multiplexer "hey girl, keep an eye on this for me" πŸ‘€

fd is the file descriptor (usually a socket) you are interested in, and events is the operation you want to do. it can be IOM_READ or IOM_WRITE. that's it, that's the menu, no secret third option, no cap πŸ“

if that operation becomes possible on that descriptor, iom_wait will return and tell you the fd and the event. like it literally shows up and is like "bestie it's happening" 😭✨

⚠️ okay important, real talk: note that the event registration is removed from the iomux_t context if it occurs. so once it fires, it's gone. you will have to call iom_requeue after you handled the event, if you are still interested in it. one-and-done energy fr fr πŸ’€
🚨 also, closing a file descriptor with registered events will discard the event registration. so like, don't expect the registration to survive that. it's giving "we don't do that here" πŸ™ˆ

πŸ”— LINKING πŸ”—

you may have to add -lpthread to the command line in the linking step. yeah. the linker is picky. she has main character energy and we respect her for it πŸ‘‘


πŸ’œ RETURN VALUE πŸ’œ

  • 0 on success β€” ate, no crumbs 🌈
  • -1 on error, setting errno β€” not the vibe, go read errno 😭

πŸ¦‹ SEE ALSO πŸ¦‹

  • iom_init
  • iom_requeue
  • iom_wait
  • iom_abort

the whole friend group, honestly. go read them next 🫢✨


and that's the page bestie!! this one's straight out of the Library Functions Manual, iom_add(3), brought to you by libowfat πŸ’– no date on this footer so we're just gonna say: it's timeless, like all the best girls πŸ’…πŸŽ€ periodt ✨

πŸ“¦ where this page comes from