… | |
… | |
81 | |
81 | |
82 | our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat |
82 | our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat |
83 | aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink |
83 | aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink |
84 | aio_fsync aio_fdatasync aio_readahead aio_rename aio_link aio_move |
84 | aio_fsync aio_fdatasync aio_readahead aio_rename aio_link aio_move |
85 | aio_group aio_nop); |
85 | aio_group aio_nop); |
86 | our @EXPORT = (@AIO_REQ, qw(aioreq_pri)); |
86 | our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice)); |
87 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
87 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
88 | min_parallel max_parallel max_outstanding nreqs); |
88 | min_parallel max_parallel max_outstanding nreqs); |
89 | |
89 | |
90 | @IO::AIO::GRP::ISA = 'IO::AIO::REQ'; |
90 | @IO::AIO::GRP::ISA = 'IO::AIO::REQ'; |
91 | |
91 | |
… | |
… | |
132 | is C<0>, the minimum and maximum priorities are C<-4> and C<4>, |
132 | is C<0>, the minimum and maximum priorities are C<-4> and C<4>, |
133 | respectively. Requests with higher priority will be serviced first. |
133 | respectively. Requests with higher priority will be serviced first. |
134 | |
134 | |
135 | The priority will be reset to C<0> after each call to one of the C<aio_> |
135 | The priority will be reset to C<0> after each call to one of the C<aio_> |
136 | functions. |
136 | functions. |
|
|
137 | |
|
|
138 | Example: open a file with low priority, then read something from it with |
|
|
139 | higher priority so the read request is serviced before other low priority |
|
|
140 | open requests (potentially spamming the cache): |
|
|
141 | |
|
|
142 | aioreq_pri -3; |
|
|
143 | aio_open ..., sub { |
|
|
144 | return unless $_[0]; |
|
|
145 | |
|
|
146 | aioreq_pri -2; |
|
|
147 | aio_read $_[0], ..., sub { |
|
|
148 | ... |
|
|
149 | }; |
|
|
150 | }; |
|
|
151 | |
|
|
152 | =item aioreq_nice $pri_adjust |
|
|
153 | |
|
|
154 | Similar to C<aioreq_pri>, but subtracts the given value from the current |
|
|
155 | priority, so effects are cumulative. |
137 | |
156 | |
138 | =item aio_open $pathname, $flags, $mode, $callback->($fh) |
157 | =item aio_open $pathname, $flags, $mode, $callback->($fh) |
139 | |
158 | |
140 | Asynchronously open or create a file and call the callback with a newly |
159 | Asynchronously open or create a file and call the callback with a newly |
141 | created filehandle for the file. |
160 | created filehandle for the file. |