iom_wait(3)

πŸ’– iom_wait β€” wait for event from I/O multiplexer πŸ’–

okay bestie, welcome to iom_wait(3), straight out of the Library Functions Manual, section 3, and it's literally the moment your whole event loop has been waiting for (pun fully intended). sit down, grab a boba, let's get into it πŸ§‹βœ¨


🌸 SYNTAX 🌸

#include <libowfat/io.h>

int iom_wait(iomux_t* c,
                   int64* fd, unsigned int* events,
                   unsigned long timeout);

look at her. so simple. so iconic. πŸ’…


✨ DESCRIPTION ✨

so iom_wait is the function that just... chills and waits for events that got registered to the I/O multiplexer with iom_add. she'll wait for timeout milliseconds. that's it, that's the vibe.

if during that time any of the registered events actually occur, iom_wait sets fd to the file descriptor the event happened on, and sets events to the sum of IOM_READ, IOM_WRITE and IOM_ERROR, depending on what event actually happened. then she returns 1. slay. πŸŽ€

if nothing happens during that time? she returns 0 and leaves fd and events completely alone. no touchy. πŸ™ˆ

⚠️ important note, bestie: the event registration is removed from the iomux_t context if it occurs. so you will have to call iom_wait again after you handled the event, if you are still interested in it. she's not gonna keep reminding you. it's giving one-and-done. πŸ’€

also, closing a file descriptor with registered events will discard the event registration. bye bye registration, you will not be missed πŸ¦‹


πŸ”— LINKING πŸ”—

you may have to add -lpthread to the command line in the linking step. ngl, don't forget it, the linker will be so dramatic about it otherwise. 😭


πŸ‘‘ RETURN VALUE πŸ‘‘

  • 1 β€” on success, queen behaviour πŸ’–
  • 0 β€” if there was a timeout, nothing happened, no biggie
  • -1 β€” on error, and she sets errno so you know what went wrong πŸ”₯
  • -2 β€” if iom_abort was called on the I/O multiplexer context

periodt.


🌈 SEE ALSO 🌈

  • iom_init
  • iom_add
  • iom_abort

and that's the whole page, bestie 🫢 this was iom_wait(3) from the Library Functions Manual, third section energy, and she ate and left no crumbs. now go handle your events and remember to re-register them, i'm literally begging you πŸ’œπŸŒΈβœ¨