IO::As...p::Glib(3pm)

πŸ“¦
version 0.22 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– IO::Async::Loop::Glib β€” the manual, but make it cute πŸ’–

okay bestie, gather round 🫢 this is the page for IO::Async::Loop::Glib(3pm), from the User Contributed Perl Documentation corner of the internet, and it's genuinely one of those little glues that makes everything slay.

✨ NAME ✨

"IO::Async::Loop::Glib" β€” use "IO::Async" with Glib or GTK. that's it, that's the whole vibe πŸ’…

🌸 SYNOPSIS 🌸

use IO::Async::Loop::Glib;

my $loop = IO::Async::Loop::Glib->new();

$loop->add( ... );

...
# Rest of GLib/Gtk program that uses GLib

Glib::MainLoop->new->run();

Or literally just:

$loop->run;

Or, if you're feeling hand-on-the-wheel about it:

while(1) {
   $loop->loop_once();
}

three ways to run the thing, pick your fighter πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

So this is a subclass of "IO::Async::Loop", right, and what it does is use the "Glib::MainLoop" to do its read-ready and write-ready tests. no cap. that's the whole job.

The appropriate "Glib::IO" sources get added to or removed from the "Glib::MainLoop" whenever notifiers get added to or removed from the set, or whenever they change their want_writeready status. and the callbacks? Glib itself calls them automatically, like the main character it is. πŸŽ€ no special methods on this loop object required β€” none, zero, nada.


πŸ‘‘ CONSTRUCTOR πŸ‘‘

✨ new ✨

$loop = IO::Async::Loop::Glib->new()

This gives you back a fresh new instance of an "IO::Async::Loop::Glib" object. It takes no special arguments. none. it's low maintenance, it's giving minimalist queen πŸ’œ


πŸ’… METHODS πŸ’…

There are no special methods in this subclass, other than the ones you already get from the "IO::Async::Loop" base class. it inherited everything and added nothing, iconic behaviour honestly.

🌈 loop_once 🌈

$loop->loop_once( $timeout )

This one calls the iteration() method on the underlying "Glib::MainContext". If you hand it a timeout value, then a Glib timeout gets installed to interrupt the loop at that time β€” so it won't just sit there forever, promise πŸ™ˆ

Now listen: if Glib says any callbacks were fired, this method returns 1. But β€” and this is the important bit, don't skip it β€” that does not mean any "IO::Async" callbacks were invoked, because there may be other parts of your code sharing the Glib main context. they're all in the group chat, y'know? Otherwise, it returns 0.

so: 1 = Glib fired something. not necessarily yours. stay woke πŸ’€

πŸŽ€ SEE ALSO πŸŽ€

  • Glib β€” Perl wrappers for the GLib utility and Object libraries
  • Gtk2 β€” Perl interface to the 2.x series of the Gimp Toolkit library

both fr fr worth a look if you're going deeper πŸ¦‹


⭐ AUTHOR ⭐

Paul Evans <leonerd@leonerd.org.uk> β€” the legend himself, we stan πŸ‘‘


and that's the page!! mwah πŸ’‹ this was perl v5.38.2, dated 2024-02-25, served up in the classic IO::As...p::Glib(3pm) fit. go loop some things bestie, you're gonna eat βœ¨πŸ’–

πŸ“¦ where this page comes from