ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/AIO.pm
(Generate patch)

Comparing IO-AIO/AIO.pm (file contents):
Revision 1.180 by root, Wed Mar 31 00:46:18 2010 UTC vs.
Revision 1.181 by root, Tue May 4 21:14:01 2010 UTC

4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use IO::AIO; 7 use IO::AIO;
8 8
9 aio_open "/etc/passwd", O_RDONLY, 0, sub { 9 aio_open "/etc/passwd", IO::AIO::O_RDONLY, 0, sub {
10 my $fh = shift 10 my $fh = shift
11 or die "/etc/passwd: $!"; 11 or die "/etc/passwd: $!";
12 ... 12 ...
13 }; 13 };
14 14
76 76
77 # register the IO::AIO callback with EV 77 # register the IO::AIO callback with EV
78 my $aio_w = EV::io IO::AIO::poll_fileno, EV::READ, \&IO::AIO::poll_cb; 78 my $aio_w = EV::io IO::AIO::poll_fileno, EV::READ, \&IO::AIO::poll_cb;
79 79
80 # queue the request to open /etc/passwd 80 # queue the request to open /etc/passwd
81 aio_open "/etc/passwd", O_RDONLY, 0, sub { 81 aio_open "/etc/passwd", IO::AIO::O_RDONLY, 0, sub {
82 my $fh = shift 82 my $fh = shift
83 or die "error while opening: $!"; 83 or die "error while opening: $!";
84 84
85 # stat'ing filehandles is generally non-blocking 85 # stat'ing filehandles is generally non-blocking
86 my $size = -s $fh; 86 my $size = -s $fh;
352by the umask in effect then the request is being executed, so better never 352by the umask in effect then the request is being executed, so better never
353change the umask. 353change the umask.
354 354
355Example: 355Example:
356 356
357 aio_open "/etc/passwd", O_RDONLY, 0, sub { 357 aio_open "/etc/passwd", IO::AIO::O_RDONLY, 0, sub {
358 if ($_[0]) { 358 if ($_[0]) {
359 print "open successful, fh is $_[0]\n"; 359 print "open successful, fh is $_[0]\n";
360 ... 360 ...
361 } else { 361 } else {
362 die "open failed: $!\n"; 362 die "open failed: $!\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines