… | |
… | |
27 | \&IO::AIO::poll_cb; |
27 | \&IO::AIO::poll_cb; |
28 | |
28 | |
29 | # Tk |
29 | # Tk |
30 | Tk::Event::IO->fileevent (IO::AIO::poll_fileno, "", |
30 | Tk::Event::IO->fileevent (IO::AIO::poll_fileno, "", |
31 | readable => \&IO::AIO::poll_cb); |
31 | readable => \&IO::AIO::poll_cb); |
|
|
32 | |
|
|
33 | # Danga::Socket |
|
|
34 | Danga::Socket->AddOtherFds (IO::AIO::poll_fileno => |
|
|
35 | \&IO::AIO::poll_cb); |
|
|
36 | |
32 | |
37 | |
33 | =head1 DESCRIPTION |
38 | =head1 DESCRIPTION |
34 | |
39 | |
35 | This module implements asynchronous I/O using whatever means your |
40 | This module implements asynchronous I/O using whatever means your |
36 | operating system supports. |
41 | operating system supports. |
… | |
… | |
54 | use base 'Exporter'; |
59 | use base 'Exporter'; |
55 | |
60 | |
56 | use Fcntl (); |
61 | use Fcntl (); |
57 | |
62 | |
58 | BEGIN { |
63 | BEGIN { |
59 | $VERSION = 0.2; |
64 | $VERSION = 0.3; |
60 | |
65 | |
61 | @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 |
62 | aio_fsync aio_fdatasync aio_readahead); |
67 | aio_fsync aio_fdatasync aio_readahead); |
63 | @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); |
64 | |
69 | |
… | |
… | |
128 | |
133 | |
129 | Example: Read 15 bytes at offset 7 into scalar C<$buffer>, strating at |
134 | Example: Read 15 bytes at offset 7 into scalar C<$buffer>, strating at |
130 | offset C<0> within the scalar: |
135 | offset C<0> within the scalar: |
131 | |
136 | |
132 | aio_read $fh, 7, 15, $buffer, 0, sub { |
137 | aio_read $fh, 7, 15, $buffer, 0, sub { |
133 | $_[0] >= 0 or die "read error: $!"; |
138 | $_[0] > 0 or die "read error: $!"; |
134 | print "read <$buffer>\n"; |
139 | print "read $_[0] bytes: <$buffer>\n"; |
135 | }; |
140 | }; |
136 | |
141 | |
137 | =item aio_readahead $fh,$offset,$length, $callback |
142 | =item aio_readahead $fh,$offset,$length, $callback |
138 | |
143 | |
139 | Asynchronously reads the specified byte range into the page cache, using |
144 | Asynchronously reads the specified byte range into the page cache, using |