gensio_glib_funcs_alloc(3)

πŸ’– gensio_glib_funcs_alloc β€” bestie edition πŸ’–

okay so this is a page from the gensio library functions manual, and we're talking about gensio_glib_funcs_alloc β€” yes the whole thing, say it with your chest. let's get into it 🫢


✨ NAME ✨

gensio_glib_funcs_alloc β€” an abstraction for some operating system functions, but make it glib 🌈


✨ SYNOPSIS ✨

#include <gensio/gensio_glib.h>

int gensio_glib_funcs_alloc(struct gensio_os_funcs **o)

✨ DESCRIPTION ✨

So this structure gives the gensio library an abstraction layer that lets it vibe on top of glib. πŸ’… If you wanna know what that actually does under the hood, go read the gensio_os_funcs.3 man page, it's all laid out there. The whole point of this one? If you've got a project already living its glib-based life and you wanna fold gensio into it β€” this is your girl. πŸŽ€

ngl though, she comes with some limitations 😭 β€” that's not gensio's fault, it's because of weaknesses in the glib interface itself.

If you use this, you really wanna be using the gensio wait functions, not g_cont_wait..() by yourself. Like, fr fr. Do you strictly have to? No, bestie, you don't β€” especially if your app is single threaded, you can do whatever. But especially in multithreaded apps, you absolutely cannot mix calls to the os funcs wait functions and the glib wait functions. Which means you can't use the blocking functions, because all of those use os func waiters. πŸ’€

Performance-wise? Should be fine β€” ok for a single thread. βœ… But for multiple threads, only one thing at a time can be waiting on the main glib thread. That's a weakness in glib, not us, we're just reporting the tea. β˜• For multiple threads, one function sits in the main context and the others sit on condition variables. Then, when the thread sitting on the main context wakes up, it wakes another waiting thread to take over. πŸ” iconic relay race energy honestly.

If performance is actually important to you, it might be better to put glib on top of gensio os funcs using g_main_context_set_poll_func(). I leave that as an exercise to the reader. πŸ˜ŒπŸ“š (yes, you. go do your homework.)


✨ RETURN VALUES ✨

A gensio_err returns a standard gensio error. That's it, that's the whole vibe check. ⭐


✨ SEE ALSO ✨


and that's a wrap on gensio_glib_funcs_alloc(3), bestie!! πŸ’œ this one's from the Library Functions Manual, dated 03 Feb 2021, and yes the source/version tag at the bottom is literally just gensio_glib_funcs_alloc(3) β€” she said her own name and left. periodt. πŸ‘‘βœ¨πŸŒΈ

πŸ“¦ where this page comes from