AnyEvent::Impl::Tk(3)

Bestie, welcome to AnyEvent::Impl::Tk(3), fresh from the User Contributed Perl Documentation pile, and it's giving "AnyEvent adaptor for Tk" with a side of chaotic Tk slander ๐Ÿ’…โœจ

โœจ NAME โœจ

  • AnyEvent::Impl::Tk โ€” AnyEvent adaptor for Tk. That's the whole name, periodt ๐ŸŽ€

๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

use AnyEvent;
use Tk;

# this module gets loaded automatically as required

๐Ÿ’… DESCRIPTION ๐Ÿ’…

This module provides transparent support for AnyEvent. You literally don't have to do anything to make Tk work with AnyEvent except by loading Tk before creating the first AnyEvent watcher. That's it. No secret handshake, no extra setup, just load Tk first and vibe ๐Ÿซถ

Okay, now hold my hand while we get into it: Tk is buggy. Tk is extremely buggy. Tk is so unbelievably buggy that for each bug reported and fixed, you get one new bug followed by reintroduction of the old bug in a later revision ๐Ÿ˜ญ It is also basically unmaintained: the maintainers are not even interested in improving the situation โ€” reporting bugs is considered rude, and fixing bugs is considered changing holy code, so it's apparently better to leave it broken. The author regularly runs out of words to describe how bad it really is ๐Ÿ’€

To work around some of the many, many bugs in Tk that don't get fixed, this adaptor dup()'s all filehandles that get passed into its I/O watchers. So if you register a read and a write watcher for one fh, AnyEvent will create two additional file descriptors (and handles) ๐Ÿ˜ฎโ€๐Ÿ’จ

This creates a high overhead and is slow, but seems to work around most known bugs in Tk::fileevent on 32 bit architectures (Tk seems to be terminally broken on 64 bit, do not expect more than 10 or so watchers to work on 64 bit machines). Lowkey a whole situation, but there it is ๐Ÿฆ‹

Do not expect these workarounds to avoid segfaults and crashes inside Tk. Like, they are not a magical little shield, bestie ๐Ÿ˜ญ๐Ÿ›ก๏ธ

Note also that Tk event ids wrap around after 2**32 or so events, which on the author's machine can happen within less than 12 hours, after which Tk will stomp on random other events and kill them. So don't run Tk programs for more than an hour or so. Consider that your official group-chat warning ๐Ÿšจ

To be able to access the Tk event loop, this module creates a main window and withdraws it immediately. This might cause flickering on some platforms, but Tk perversely requires a window to be able to wait for file handle readyness notifications. This window is always created (in this version of AnyEvent) and can be accessed as $AnyEvent::Impl::Tk::mw ๐Ÿ‘‘

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

AnyEvent, Tk โ€” go read those too, bestie ๐Ÿ“šโœจ

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Give them a little virtual hug for surviving all this Tk nonsense ๐Ÿซถ


Okay bye bestie ๐Ÿ’– โ€” source/version: perl v5.42.0 โ€ข date: 2019-09-18 โ€ข page: AnyEvent::Impl::Tk(3) โ€ข mwah, slay, and may your watchers stay un-stomped ๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from