[Israel.pm] Asychronous IO

Yuval Kogman nothingmuch at woobling.org
Fri Dec 4 13:42:08 PST 2009


I think required background would be a 5 minute intro on how to do
this "by hand" with a select() loop. Understanding how an event loop
is built on top of that simple primitive (or its more modern
replacements) is very helpful in getting a view of the big picture,
especially when resource management becomes an issue.

I would also recommend looking at AnyEvent::Handle next, since it's a
pretty thin wrapper on top of that level of stuff.

IO::Lambda provides a very high level abstraction for event driven
stream processing, with several event based drivers.

POE is a similarly high level abstraction layer, but it has a very
structured OO approach for organizing large applications in a very
different way from IO::Lambda (no opinion on "better" or "worse" ;-).

Secondly, IO::AIO exposes POSIX aio which is a very different approach
to nonblocking IO, each AIO request is sort of like a thread that can
only do that IO operation, so some people find that a little more
comfortable than event driven nonblocking IO, it's also worth a
mention.

Lastly, you can do async IO with ithreads by simply allocating one
worker per handle, but since ithreads are expensive that's usually not
a good way of approaching it.

A nicer solution for threaded IO (at least IMHO), is Coro and
Coro::Handle, which uses AnyEvent::Handle as the underlying
nonblocking IO framework but wraps it in blocking primitives.

FWIW, I would be happy to give one or more presentation(s) on any
combination of these things if there is still interest and Peter
hasn't covered them, but only after I come back in Israel in March.


More information about the Perl mailing list