--- AnyEvent/lib/AnyEvent.pm 2008/05/29 03:45:37 1.145 +++ AnyEvent/lib/AnyEvent.pm 2008/06/05 08:10:10 1.154 @@ -1,4 +1,4 @@ -=head1 => NAME +=head1 NAME AnyEvent - provide framework for multiple event loops @@ -20,6 +20,12 @@ $w->send; # wake up current and all future recv's $w->recv; # enters "main loop" till $condvar gets ->send +=head1 INTRODUCTION/TUTORIAL + +This manpage is mainly a reference manual. If you are interested +in a tutorial or some gentle introduction, have a look at the +L manpage. + =head1 WHY YOU SHOULD USE THIS MODULE (OR NOT) Glib, POE, IO::Async, Event... CPAN offers event models by the dozen @@ -134,10 +140,10 @@ An any way to achieve that is this pattern: - my $w; $w = AnyEvent->type (arg => value ..., cb => sub { - # you can use $w here, for example to undef it - undef $w; - }); + my $w; $w = AnyEvent->type (arg => value ..., cb => sub { + # you can use $w here, for example to undef it + undef $w; + }); Note that C combination. This is necessary because in Perl, my variables are only visible after the statement in which they are @@ -348,21 +354,21 @@ Example: fork a process and wait for it - my $done = AnyEvent->condvar; - - my $pid = fork or exit 5; - - my $w = AnyEvent->child ( - pid => $pid, - cb => sub { - my ($pid, $status) = @_; - warn "pid $pid exited with status $status"; - $done->send; - }, - ); - - # do something else, then wait for process exit - $done->recv; + my $done = AnyEvent->condvar; + + my $pid = fork or exit 5; + + my $w = AnyEvent->child ( + pid => $pid, + cb => sub { + my ($pid, $status) = @_; + warn "pid $pid exited with status $status"; + $done->send; + }, + ); + + # do something else, then wait for process exit + $done->recv; =head2 CONDITION VARIABLES @@ -593,8 +599,9 @@ replaces it before doing so. The callback will be called when the condition becomes "true", i.e. when -C or C are called. Calling C inside the callback -or at any later time is guaranteed not to block. +C or C are called, with the only argument being the condition +variable itself. Calling C inside the callback or at any later time +is guaranteed not to block. =back @@ -802,7 +809,7 @@ use Carp; -our $VERSION = '4.1'; +our $VERSION = 4.14; our $MODEL; our $AUTOLOAD; @@ -1168,7 +1175,7 @@ For example, to force the pure perl model (L) you could start your program like this: - PERL_ANYEVENT_MODEL=Perl perl ... + PERL_ANYEVENT_MODEL=Perl perl ... =item C @@ -1653,9 +1660,9 @@ You can make AnyEvent completely ignore this variable by deleting it before the first watcher gets created, e.g. with a C block: - BEGIN { delete $ENV{PERL_ANYEVENT_MODEL} } - - use AnyEvent; + BEGIN { delete $ENV{PERL_ANYEVENT_MODEL} } + + use AnyEvent; Similar considerations apply to $ENV{PERL_ANYEVENT_VERBOSE}, as that can be used to probe what backend is used and gain other information (which is @@ -1686,8 +1693,8 @@ =head1 AUTHOR - Marc Lehmann - http://home.schmorp.de/ + Marc Lehmann + http://home.schmorp.de/ =cut