AnyEvent::Impl::IOAsync(3pm) | User Contributed Perl Documentation | AnyEvent::Impl::IOAsync(3pm) |
AnyEvent::Impl::IOAsync - AnyEvent adaptor for IO::Async
use AnyEvent; use IO::Async::Loop; # optionally set another event loop use AnyEvent::Impl::IOAsync; my $loop = new IO::Async::Loop; AnyEvent::Impl::IOAsync::set_loop $loop;
This module provides support for IO::Async as AnyEvent backend. It supports I/O, timers, signals and child process watchers. Idle watchers are emulated. I/O watchers need to dup their fh because IO::Async only supports IO handles, not plain file descriptors.
The only user-servicible part in this module is the "set_loop" function and $LOOP variable:
This module is no exception. It creates a new IO::Async::Loop object when it is loaded. This might not be the right loop object, though, and thus you can replace it by a call to this function with the loop object of your choice.
Note that switching loops while watchers are already initialised can have unexpected effects, and is not supported unless you can live with the consequences.
Storing the "default" loop makes this module a possible arbiter for other modules that want to use IO::Async transparently. It's advised to directly refer to this variable each time you want to use it, without making a local copy.
This section had a long list of problems and shortcomings that made it almost impossible to support IO::Async. With version 0.33 of IO::Async, however, most of these have been fixed, so IO::Async can now be used as easily as many other loops.
There are a few remaining problems that require emulation or workarounds:
For I/O watchers, AnyEvent has to dup() every file handle, as IO::Async fails to support the same or different file handles pointing to the same fd (the good thing is that it is documented, but why not fix it instead?).
Apart from these fatal flaws, there are a number of unpleasent properties that just need some mentioning:
The method naming is chaotic: "watch_child" creates a child watcher, but "watch_io" is an internal method; "detach_signal" removes a signal watcher, but "detach_child" forks a subprocess and so on).
On the positive side, performance with IO::Async is quite good even in my very demanding eyes.
AnyEvent, IO::Async.
Marc Lehmann <schmorp@schmorp.de> http://anyevent.schmorp.de Paul Evans <leonerd@leonerd.org.uk> Rewrote the backend for IO::Async version 0.33.
2019-03-02 | perl v5.28.1 |