iom_init(3)

✨ iom_init(3) ✨

okay bestie, pull up a chair, we're learning about iom_init from the Library Functions Manual πŸ’– yes this is the one that makes you a brand new I/O multiplexer. iconic behavior honestly.


πŸŽ€ NAME πŸŽ€

iom_init β€” create new I/O multiplexer


🌸 SYNTAX 🌸

#include <libowfat/io.h>

int iom_init(iomux_t* c);

like, that's it. one include, one call, one int coming back at you 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so iom_init initializes an I/O multiplexer. that's the whole vibe.

an I/O multiplexer is a context β€” think of it as a lil hangout spot where all your I/O events can chill β€” and you use it to do I/O multiplexing with support for multiple threads. yes bestie, threads. plural. we're fancy.

here's the workflow, periodt:

  • add events to your multiplexer with iom_add ✨
  • then grab the next available event with iom_wait πŸ’…
  • and when you're done and want to signal all the threads about something? set a volatile global variable to tell the threads to stop, then call iom_abort to tell all pending iom_wait operations in all threads to return immediately πŸ”₯

and the actual slay of it all: after iom_init is done, iom_add and iom_wait can be called from different threads on the same context, and they will synchronize internally. no cap. it just handles it. main character energy fr fr πŸ‘‘


πŸ’œ LINKING πŸ’œ

lowkey important: you may have to add -lpthread to the command line in the linking step. don't skip it and then act surprised, i'm begging πŸ™ˆ


🌈 RETURN VALUE 🌈

  • 0 β€” success, we ate πŸ’…
  • -1 β€” error, and it sets errno so you can go find out what happened

⭐ SEE ALSO ⭐

  • iom_add
  • iom_wait
  • iom_abort

go read those next bestie, they're literally the rest of the story 🧚


mwah πŸ’‹ that was iom_init(3) from the Library Functions Manual β€” go forth and multiplex responsibly, i believe in you πŸŽ€βœ¨