[Rehovot-pm] [Israel.pm] Asychronous IO
Peter Gordon
peter at pg-consultants.com
Sat Dec 5 22:57:41 PST 2009
As you point out, there are a number of ways of doing asynchronous IO.
Given the number of packages, deciding which path to take becomes a
non-trivial choice.
The difference between Coro and the other choices, is that Coro is
threaded, and all of the other solutions are single-threaded. The are a
number of differences between writing a single threaded aysnc
application and a multi-threaded application. Threading means timing
problems, semaphores and the rest of the overhead that goes with
threading. Plus, debugging timing problems is hard.
Peter
On Fri, 2009-12-04 at 23:42 +0200, Yuval Kogman wrote:
> 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.
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://mail.perl.org.il/mailman/listinfo/perl
More information about the Rehovot-pm
mailing list