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.68 by root, Tue Oct 24 03:17:39 2006 UTC vs.
Revision 1.71 by root, Tue Oct 24 11:57:30 2006 UTC

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
133respectively. Requests with higher priority will be serviced first. 133respectively. Requests with higher priority will be serviced first.
134 134
135The priority will be reset to C<0> after each call to one of the C<aio_> 135The priority will be reset to C<0> after each call to one of the C<aio_>
136functions. 136functions.
137 137
138Example: open a file with low priority, then read something from it with
139higher priority so the read request is serviced before other low priority
140open 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
154Similar to C<aioreq_pri>, but subtracts the given value from the current
155priority, so effects are cumulative.
156
138=item aio_open $pathname, $flags, $mode, $callback->($fh) 157=item aio_open $pathname, $flags, $mode, $callback->($fh)
139 158
140Asynchronously open or create a file and call the callback with a newly 159Asynchronously open or create a file and call the callback with a newly
141created filehandle for the file. 160created filehandle for the file.
142 161
193 $_[0] > 0 or die "read error: $!"; 212 $_[0] > 0 or die "read error: $!";
194 print "read $_[0] bytes: <$buffer>\n"; 213 print "read $_[0] bytes: <$buffer>\n";
195 }; 214 };
196 215
197=item aio_move $srcpath, $dstpath, $callback->($status) 216=item aio_move $srcpath, $dstpath, $callback->($status)
198
199[EXPERIMENTAL due to internal aio_group use]
200 217
201Try to move the I<file> (directories not supported as either source or 218Try to move the I<file> (directories not supported as either source or
202destination) from C<$srcpath> to C<$dstpath> and call the callback with 219destination) from C<$srcpath> to C<$dstpath> and call the callback with
203the C<0> (error) or C<-1> ok. 220the C<0> (error) or C<-1> ok.
204 221
356 373
357The callback a single argument which is either C<undef> or an array-ref 374The callback a single argument which is either C<undef> or an array-ref
358with the filenames. 375with the filenames.
359 376
360=item aio_scandir $path, $maxreq, $callback->($dirs, $nondirs) 377=item aio_scandir $path, $maxreq, $callback->($dirs, $nondirs)
361
362[EXPERIMENTAL due to internal aio_group use]
363 378
364Scans a directory (similar to C<aio_readdir>) but additionally tries to 379Scans a directory (similar to C<aio_readdir>) but additionally tries to
365separate the entries of directory C<$path> into two sets of names, ones 380separate the entries of directory C<$path> into two sets of names, ones
366you can recurse into (directories or links to them), and ones you cannot 381you can recurse into (directories or links to them), and ones you cannot
367recurse into (everything else). 382recurse into (everything else).
529 544
530[EXPERIMENTAL] 545[EXPERIMENTAL]
531 546
532This is a very special aio request: Instead of doing something, it is a 547This is a very special aio request: Instead of doing something, it is a
533container for other aio requests, which is useful if you want to bundle 548container for other aio requests, which is useful if you want to bundle
534many requests into a single, composite, request. 549many requests into a single, composite, request with a definite callback
550and the ability to cancel the whole request with its subrequests.
535 551
536Returns an object of class L<IO::AIO::GRP>. See its documentation below 552Returns an object of class L<IO::AIO::GRP>. See its documentation below
537for more info. 553for more info.
538 554
539Example: 555Example:
558phase and still requires a worker thread. Thus, the callback will not 574phase and still requires a worker thread. Thus, the callback will not
559be executed immediately but only after other requests in the queue have 575be executed immediately but only after other requests in the queue have
560entered their execution phase. This can be used to measure request 576entered their execution phase. This can be used to measure request
561latency. 577latency.
562 578
563=item IO::AIO::aio_sleep $fractional_seconds, $callback->() *NOT EXPORTED* 579=item IO::AIO::aio_busy $fractional_seconds, $callback->() *NOT EXPORTED*
564 580
565Mainly used for debugging and benchmarking, this aio request puts one of 581Mainly used for debugging and benchmarking, this aio request puts one of
566the request workers to sleep for the given time. 582the request workers to sleep for the given time.
567 583
568While it is theoretically handy to have simple I/O scheduling requests 584While it is theoretically handy to have simple I/O scheduling requests
569like sleep and file handle readable/writable, the overhead this creates 585like sleep and file handle readable/writable, the overhead this creates is
570is immense, so do not use this function except to put your application 586immense (it blocks a thread for a long time) so do not use this function
571under artificial I/O pressure. 587except to put your application under artificial I/O pressure.
572 588
573=back 589=back
574 590
575=head2 IO::AIO::REQ CLASS 591=head2 IO::AIO::REQ CLASS
576 592

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines