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

Comparing AnyEvent/lib/AnyEvent.pm (file contents):
Revision 1.317 by root, Wed Mar 24 21:22:57 2010 UTC vs.
Revision 1.318 by root, Wed Mar 24 23:28:06 2010 UTC

7 7
8=head1 SYNOPSIS 8=head1 SYNOPSIS
9 9
10 use AnyEvent; 10 use AnyEvent;
11 11
12 # if you prefer function calls, look at the L<AE> manpage for
13 # an alternative API.
14
12 # file descriptor readable 15 # file handle or descriptor readable
13 my $w = AnyEvent->io (fh => $fh, poll => "r", cb => sub { ... }); 16 my $w = AnyEvent->io (fh => $fh, poll => "r", cb => sub { ... });
14 17
15 # one-shot or repeating timers 18 # one-shot or repeating timers
16 my $w = AnyEvent->timer (after => $seconds, cb => sub { ... }); 19 my $w = AnyEvent->timer (after => $seconds, cb => sub { ... });
17 my $w = AnyEvent->timer (after => $seconds, interval => $seconds, cb => ... 20 my $w = AnyEvent->timer (after => $seconds, interval => $seconds, cb => ...
1342 1345
1343=head1 SIMPLIFIED AE API 1346=head1 SIMPLIFIED AE API
1344 1347
1345Starting with version 5.0, AnyEvent officially supports a second, much 1348Starting with version 5.0, AnyEvent officially supports a second, much
1346simpler, API that is designed to reduce the calling, typing and memory 1349simpler, API that is designed to reduce the calling, typing and memory
1347overhead. 1350overhead by using function call syntax and a fixed number of parameters.
1348 1351
1349See the L<AE> manpage for details. 1352See the L<AE> manpage for details.
1350 1353
1351=cut 1354=cut
1352 1355
1353package AE; 1356package AE;
1354 1357
1355our $VERSION = $AnyEvent::VERSION; 1358our $VERSION = $AnyEvent::VERSION;
1359
1360# fall back to the main API by default - backends and AnyEvent::Base
1361# implementations can overwrite these.
1356 1362
1357sub io($$$) { 1363sub io($$$) {
1358 AnyEvent->io (fh => $_[0], poll => $_[1] ? "w" : "r", cb => $_[2]) 1364 AnyEvent->io (fh => $_[0], poll => $_[1] ? "w" : "r", cb => $_[2])
1359} 1365}
1360 1366
2075 2081
2076The actual code goes further and collects all errors (C<die>s, exceptions) 2082The actual code goes further and collects all errors (C<die>s, exceptions)
2077that occurred during request processing. The C<result> method detects 2083that occurred during request processing. The C<result> method detects
2078whether an exception as thrown (it is stored inside the $txn object) 2084whether an exception as thrown (it is stored inside the $txn object)
2079and just throws the exception, which means connection errors and other 2085and just throws the exception, which means connection errors and other
2080problems get reported tot he code that tries to use the result, not in a 2086problems get reported to the code that tries to use the result, not in a
2081random callback. 2087random callback.
2082 2088
2083All of this enables the following usage styles: 2089All of this enables the following usage styles:
2084 2090
20851. Blocking: 20911. Blocking:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines