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.5 by root, Sun Jul 10 21:04:24 2005 UTC vs.
Revision 1.11 by root, Mon Jul 11 00:51:32 2005 UTC

3IO::AIO - Asynchronous Input/Output 3IO::AIO - Asynchronous Input/Output
4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use IO::AIO; 7 use IO::AIO;
8
9 aio_open "/etc/passwd", O_RDONLY, 0, sub {
10 my ($fh) = @_;
11 ...
12 };
13
14 aio_unlink "/tmp/file", sub { };
15
16 aio_read $fh, 30000, 1024, $buffer, 0, sub {
17 $_[0] > 0 or die "read error: $!";
18 };
19
20 # Event
21 Event->io (fd => IO::AIO::poll_fileno,
22 poll => 'r',
23 cb => \&IO::AIO::poll_cb);
24
25 # Glib/Gtk2
26 add_watch Glib::IO IO::AIO::poll_fileno,
27 \&IO::AIO::poll_cb;
28
29 # Tk
30 Tk::Event::IO->fileevent (IO::AIO::poll_fileno, "",
31 readable => \&IO::AIO::poll_cb);
32
33 # Danga::Socket
34 Danga::Socket->AddOtherFds (IO::AIO::poll_fileno =>
35 \&IO::AIO::poll_cb);
36
8 37
9=head1 DESCRIPTION 38=head1 DESCRIPTION
10 39
11This module implements asynchronous I/O using whatever means your 40This module implements asynchronous I/O using whatever means your
12operating system supports. 41operating system supports.
30use base 'Exporter'; 59use base 'Exporter';
31 60
32use Fcntl (); 61use Fcntl ();
33 62
34BEGIN { 63BEGIN {
35 $VERSION = 0.2; 64 $VERSION = 0.3;
36 65
37 @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink 66 @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink
38 aio_fsync aio_fdatasync aio_readahead); 67 aio_fsync aio_fdatasync aio_readahead);
39 @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel max_outstanding nreqs); 68 @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel max_outstanding nreqs);
40 69
104 133
105Example: Read 15 bytes at offset 7 into scalar C<$buffer>, strating at 134Example: Read 15 bytes at offset 7 into scalar C<$buffer>, strating at
106offset C<0> within the scalar: 135offset C<0> within the scalar:
107 136
108 aio_read $fh, 7, 15, $buffer, 0, sub { 137 aio_read $fh, 7, 15, $buffer, 0, sub {
109 $_[0] >= 0 or die "read error: $!"; 138 $_[0] > 0 or die "read error: $!";
110 print "read <$buffer>\n"; 139 print "read $_[0] bytes: <$buffer>\n";
111 }; 140 };
112 141
113=item aio_readahead $fh,$offset,$length, $callback 142=item aio_readahead $fh,$offset,$length, $callback
114 143
115Asynchronously reads the specified byte range into the page cache, using 144Asynchronously reads the specified byte range into the page cache, using

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines