AnyEven...l::Glib(3)
Hey bestie π welcome to AnyEven...l::Glib(3), a page from the User Contributed Perl Documentation section. This one is all about AnyEvent::Impl::Glib, and it's lowkey a whole main character moment. β¨
π NAME π
AnyEvent::Impl::Glib β an AnyEvent adaptor for Glib. That's the whole name, and yes, it's iconic. π
β¨ SYNOPSIS β¨
use AnyEvent;
use Glib;
# this module gets loaded automatically as required
So you load it, and the module does its automatic little thing when required. I'm obsessed with a module that handles itself. π
π¦ DESCRIPTION π¦
Okay so first thing: this module provides transparent support for AnyEvent. You don't have to do anything to make Glib work with AnyEvent except by loading Glib before creating the first AnyEvent watcher. That's the whole assignment, bestie. π«Ά
Now, the tea on Glib: it is probably the most inefficient event loop that has ever seen the light of the world. Not me exaggerating β Glib not only scans all its watchers (really, ALL of them, whether I/O-related, timer-related or what not) during each loop iteration, it also does so multiple times and rebuilds the poll list for the kernel each time again, dynamically even. Newer versions of libglib fortunately do not call malloc/free on every single watcher invocation, though. So... slay for the malloc/free glow-up, I guess? π
Glib also enforces certain undocumented behaviours, for example, you cannot always remove active child watchers, and the conditions on when it is valid to do so are not documented. Of course, if you get it wrong, you get GLib-CRITICAL messages. This makes it extremely hard to write "correct" glib programs, as you have to study the source code to get it right, and hope future versions don't change any internals. It's giving "read the source or perish," fr fr. π
AnyEvent implements the necessary workarounds, at a small performance cost. So yeah, it's carrying the team a little bit. π«Ά
On the positive side, and most importantly, when it works, Glib generally works correctly, no quarrels there. We love a functional moment. π
If you create many watchers (as in: more than two), you might consider one of the Glib::EV, EV::Glib or Glib::Event modules that map Glib to other, more efficient, event loops. That's your sign to upgrade the vibe if the watcher count is getting highkey out of hand. β
This module uses the default Glib main context for all its watchers. Iconic default-context behaviour, periodt. π
π SEE ALSO π
AnyEventGlib
Go read those too, bestie β iykyk. π¦
π AUTHOR π
Marc Lehmann <schmorp@schmorp.de>http://anyevent.schmorp.de
Absolute legend behavior, ngl. π
And that's the whole page, bestie! This little icon is from perl v5.42.0, dated 2019-09-18, and it lives under AnyEven...l::Glib(3). periodt π β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-AnyEvent 7.17-160000.2.2 Β· GPL-1.0-or-later OR Artistic-1.0
- opensuse-leap 16.0: perl-AnyEvent 7.17-160000.2.2 Β· GPL-1.0-or-later OR Artistic-1.0
- opensuse-leap 16.0: perl-AnyEvent 7.17-160000.2.2 Β· GPL-1.0-or-later OR Artistic-1.0
- opensuse-leap 16.0: perl-AnyEvent 7.17-160000.2.2 Β· GPL-1.0-or-later OR Artistic-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms