ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/README
(Generate patch)

Comparing AnyEvent/README (file contents):
Revision 1.47 by root, Mon Jul 20 22:39:57 2009 UTC vs.
Revision 1.48 by root, Sun Jul 26 00:17:24 2009 UTC

1NAME 1NAME
2 AnyEvent - events independent of event loop implementation 2 AnyEvent - the DBI of event loop programming
3 3
4 EV, Event, Glib, Tk, Perl, Event::Lib, Qt and POE are various supported 4 EV, Event, Glib, Tk, Perl, Event::Lib, Irssi, IO::Async, Qt and POE are
5 event loops. 5 various supported event loops/environments.
6 6
7SYNOPSIS 7SYNOPSIS
8 use AnyEvent; 8 use AnyEvent;
9 9
10 # file descriptor readable 10 # file descriptor readable
43SUPPORT 43SUPPORT
44 There is a mailinglist for discussing all things AnyEvent, and an IRC 44 There is a mailinglist for discussing all things AnyEvent, and an IRC
45 channel, too. 45 channel, too.
46 46
47 See the AnyEvent project page at the Schmorpforge Ta-Sa Software 47 See the AnyEvent project page at the Schmorpforge Ta-Sa Software
48 Respository, at <http://anyevent.schmorp.de>, for more info. 48 Repository, at <http://anyevent.schmorp.de>, for more info.
49 49
50WHY YOU SHOULD USE THIS MODULE (OR NOT) 50WHY YOU SHOULD USE THIS MODULE (OR NOT)
51 Glib, POE, IO::Async, Event... CPAN offers event models by the dozen 51 Glib, POE, IO::Async, Event... CPAN offers event models by the dozen
52 nowadays. So what is different about AnyEvent? 52 nowadays. So what is different about AnyEvent?
53 53
386 have to suffer the delays. 386 have to suffer the delays.
387 387
388 CHILD PROCESS WATCHERS 388 CHILD PROCESS WATCHERS
389 You can also watch on a child process exit and catch its exit status. 389 You can also watch on a child process exit and catch its exit status.
390 390
391 The child process is specified by the "pid" argument (if set to 0, it 391 The child process is specified by the "pid" argument (one some backends,
392 watches for any child process exit). The watcher will triggered only 392 using 0 watches for any child process exit, on others this will croak).
393 when the child process has finished and an exit status is available, not 393 The watcher will be triggered only when the child process has finished
394 on any trace events (stopped/continued). 394 and an exit status is available, not on any trace events
395 (stopped/continued).
395 396
396 The callback will be called with the pid and exit status (as returned by 397 The callback will be called with the pid and exit status (as returned by
397 waitpid), so unlike other watcher types, you *can* rely on child watcher 398 waitpid), so unlike other watcher types, you *can* rely on child watcher
398 callback arguments. 399 callback arguments.
399 400
760 761
761 AnyEvent::Impl::Glib based on Glib, slow but very stable. 762 AnyEvent::Impl::Glib based on Glib, slow but very stable.
762 AnyEvent::Impl::Tk based on Tk, very broken. 763 AnyEvent::Impl::Tk based on Tk, very broken.
763 AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. 764 AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse.
764 AnyEvent::Impl::POE based on POE, very slow, some limitations. 765 AnyEvent::Impl::POE based on POE, very slow, some limitations.
766 AnyEvent::Impl::Irssi used when running within irssi.
765 767
766 Backends with special needs. 768 Backends with special needs.
767 Qt requires the Qt::Application to be instantiated first, but will 769 Qt requires the Qt::Application to be instantiated first, but will
768 otherwise be picked up automatically. As long as the main program 770 otherwise be picked up automatically. As long as the main program
769 instantiates the application before any AnyEvent watchers are 771 instantiates the application before any AnyEvent watchers are
834 creates and installs the global IO::AIO watcher in a "post_detect" 836 creates and installs the global IO::AIO watcher in a "post_detect"
835 block to avoid autodetecting the event module at load time. 837 block to avoid autodetecting the event module at load time.
836 838
837 If called in scalar or list context, then it creates and returns an 839 If called in scalar or list context, then it creates and returns an
838 object that automatically removes the callback again when it is 840 object that automatically removes the callback again when it is
841 destroyed (or "undef" when the hook was immediately executed). See
839 destroyed. See Coro::BDB for a case where this is useful. 842 AnyEvent::AIO for a case where this is useful.
843
844 Example: Create a watcher for the IO::AIO module and store it in
845 $WATCHER. Only do so after the event loop is initialised, though.
846
847 our WATCHER;
848
849 my $guard = AnyEvent::post_detect {
850 $WATCHER = AnyEvent->io (fh => IO::AIO::poll_fileno, poll => 'r', cb => \&IO::AIO::poll_cb);
851 };
852
853 # the ||= is important in case post_detect immediately runs the block,
854 # as to not clobber the newly-created watcher. assigning both watcher and
855 # post_detect guard to the same variable has the advantage of users being
856 # able to just C<undef $WATCHER> if the watcher causes them grief.
857
858 $WATCHER ||= $guard;
840 859
841 @AnyEvent::post_detect 860 @AnyEvent::post_detect
842 If there are any code references in this array (you can "push" to it 861 If there are any code references in this array (you can "push" to it
843 before or after loading AnyEvent), then they will called directly 862 before or after loading AnyEvent), then they will called directly
844 after the event loop has been chosen. 863 after the event loop has been chosen.
1758 Event::Lib, Qt, POE. 1777 Event::Lib, Qt, POE.
1759 1778
1760 Implementations: AnyEvent::Impl::EV, AnyEvent::Impl::Event, 1779 Implementations: AnyEvent::Impl::EV, AnyEvent::Impl::Event,
1761 AnyEvent::Impl::Glib, AnyEvent::Impl::Tk, AnyEvent::Impl::Perl, 1780 AnyEvent::Impl::Glib, AnyEvent::Impl::Tk, AnyEvent::Impl::Perl,
1762 AnyEvent::Impl::EventLib, AnyEvent::Impl::Qt, AnyEvent::Impl::POE, 1781 AnyEvent::Impl::EventLib, AnyEvent::Impl::Qt, AnyEvent::Impl::POE,
1763 AnyEvent::Impl::IOAsync. 1782 AnyEvent::Impl::IOAsync, Anyevent::Impl::Irssi.
1764 1783
1765 Non-blocking file handles, sockets, TCP clients and servers: 1784 Non-blocking file handles, sockets, TCP clients and servers:
1766 AnyEvent::Handle, AnyEvent::Socket, AnyEvent::TLS. 1785 AnyEvent::Handle, AnyEvent::Socket, AnyEvent::TLS.
1767 1786
1768 Asynchronous DNS: AnyEvent::DNS. 1787 Asynchronous DNS: AnyEvent::DNS.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines