… | |
… | |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use Linux::AIO; |
7 | use Linux::AIO; |
8 | |
8 | |
|
|
9 | # This module has been mostly superseded by IO::AIO. |
|
|
10 | |
9 | =head1 DESCRIPTION |
11 | =head1 DESCRIPTION |
|
|
12 | |
|
|
13 | I<This module has been mostly superseded by IO::AIO, which is API |
|
|
14 | compatible.> |
10 | |
15 | |
11 | This module implements asynchronous I/O using the means available to Linux |
16 | This module implements asynchronous I/O using the means available to Linux |
12 | - clone. It does not hook into the POSIX aio_* functions because Linux |
17 | - clone. It does not hook into the POSIX aio_* functions because Linux |
13 | does not yet support these in the kernel (even as of 2.6.12, only O_DIRECT |
18 | does not yet support these in the kernel (even as of 2.6.12, only O_DIRECT |
14 | files are supported) and even if, it would only allow aio_read and write, |
19 | files are supported) and even if, it would only allow aio_read and write, |
… | |
… | |
50 | package Linux::AIO; |
55 | package Linux::AIO; |
51 | |
56 | |
52 | use base 'Exporter'; |
57 | use base 'Exporter'; |
53 | |
58 | |
54 | BEGIN { |
59 | BEGIN { |
55 | $VERSION = 1.71; |
60 | $VERSION = 1.8; |
56 | |
61 | |
57 | @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink |
62 | @EXPORT = qw(aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink |
58 | aio_fsync aio_fdatasync aio_readahead); |
63 | aio_fsync aio_fdatasync aio_readahead); |
59 | @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs); |
64 | @EXPORT_OK = qw(poll_fileno poll_cb min_parallel max_parallel nreqs); |
60 | |
65 | |
… | |
… | |
138 | |
143 | |
139 | Example: |
144 | Example: |
140 | |
145 | |
141 | aio_open "/etc/passwd", O_RDONLY, 0, sub { |
146 | aio_open "/etc/passwd", O_RDONLY, 0, sub { |
142 | if ($_[0] >= 0) { |
147 | if ($_[0] >= 0) { |
143 | open my $fh, "<&$_[0]"; # create a copy for perl |
148 | open my $fh, "<&=$_[0]"; |
144 | aio_close $_[0], sub { }; # close the aio handle |
|
|
145 | print "open successful, fh is $fh\n"; |
149 | print "open successful, fh is $fh\n"; |
146 | ... |
150 | ... |
147 | } else { |
151 | } else { |
148 | die "open failed: $!\n"; |
152 | die "open failed: $!\n"; |
149 | } |
153 | } |