View more presentations from Tatsuhiko Miyagawa.
Here's my slides about AnyEvent YAPC::Asia 2009 day 1. I realized this is the first talk in years that I give a talk about software/modules that are not mine, though it indeed has a couple of examples from my AnyEvent::* modules.
Rocco, the author of POE pointed out that slides 19-21 are misleading since POE also has the POE::Loop concept so that you can run your event loop under different backends like EV or Gtk. While that is true (and that is great), POE still can't run with the other main loop, like IO::Async::Loop->loop_forever. You still need to call POE::Kernel->run and to do so you should rewrite your main program to use POE everywhere, since existent IO::Async based program can't run any of POE::Component, which is totally possible with AnyEvent and AnyEvent::* modules.
UPDATE: see the comment below for Rocco, maybe I was misunderstanding and POE::Session->create works with other event loops like AnyEvent modules. I still love AnyEvent's callback style cleaner and much saner Perl-ish API but yeah, if that is true i draw it back from the POE-AnyEvent battle table.
I respectfully disagree, and I have code to back me up.
POE runs with other main loops. In fact, POE::Kernel->run() is often implemented in terms of native event dispatchers. POE::Loop classes implement event watchers using native watchers, and native callbacks are used to generate POE events.
Depending on the POE::Loop implementation, POE::Kernel->run() need not be called upon to dispatch events. This is CPAN, so your mileage may vary. If you're interested in improving CPAN, submit bug reports to the appropriate queues.
I mentioned I had code. Here's a working example of POE code and native Glib code running together in the same program, using Glib's MainLoop:
Of course you can call POE::Kernel->run() instead of Glib's main loop. This is a good thing. A single, portable run() method covers every supported event loop.
Posted by: twitter.com/rcaputo | 2009.09.10 at 22:13
By the way, your style for pre-formatted text in comments seems a bit vertically sparse and not very monospaced. The preview style looked a lot better, although the textarea was kind of small.
Posted by: twitter.com/rcaputo | 2009.09.10 at 22:18
Rocco, thanks for the comment. Hmm, that was definitely something different from what I had in my mind and experimented with. I apologize for the confusion and will update the blog post to mention your comment.
Posted by: miyagawa | 2009.09.11 at 08:31
Too bad you have to rely on undocumented features (POE::Kernel says you have to call the run method). Looks like a hack to prove a point.
Even if it is possible with POE, you cannot fault people like miyagawa to misrepresent things when the official documentation supports his slides.
Posted by: remlin | 2009.09.11 at 12:25
While it "looks like a hack", a small example is much more reasonable for a blog comment than a larger, more complete program. I'm glad that it concisely proved my point.
As for POE's documentation, it does explain how to call run() so that it returns right away without taking control of the event loop. I admit it could be clearer. The original included:
...
Based on your feedback, I am changing it to read:
...
If this change is unsatisfactory or you encounter any other problems, please send bug reports and/or patches to POE's bug queue at rt.cpan.org.
Constructive dialoge with CPAN authors will increase the rate of CPAN improvement. You will want to do this if you're interested in helping Perl be a friendlier, more welcoming platform for open source development.
Posted by: twitter.com/rcaputo | 2009.09.11 at 17:04