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.87 by root, Sun Oct 29 00:52:02 2006 UTC vs.
Revision 1.105 by root, Sun Mar 25 00:20:27 2007 UTC

5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use IO::AIO; 7 use IO::AIO;
8 8
9 aio_open "/etc/passwd", O_RDONLY, 0, sub { 9 aio_open "/etc/passwd", O_RDONLY, 0, sub {
10 my ($fh) = @_; 10 my $fh = shift
11 or die "/etc/passwd: $!";
11 ... 12 ...
12 }; 13 };
13 14
14 aio_unlink "/tmp/file", sub { }; 15 aio_unlink "/tmp/file", sub { };
15 16
61etc.), but can also be used to easily do operations in parallel that are 62etc.), but can also be used to easily do operations in parallel that are
62normally done sequentially, e.g. stat'ing many files, which is much faster 63normally done sequentially, e.g. stat'ing many files, which is much faster
63on a RAID volume or over NFS when you do a number of stat operations 64on a RAID volume or over NFS when you do a number of stat operations
64concurrently. 65concurrently.
65 66
66While this works on all types of file descriptors (for example sockets), 67While most of this works on all types of file descriptors (for example
67using these functions on file descriptors that support nonblocking 68sockets), using these functions on file descriptors that support
68operation (again, sockets, pipes etc.) is very inefficient. Use an event 69nonblocking operation (again, sockets, pipes etc.) is very inefficient or
70might not work (aio_read fails on sockets/pipes/fifos). Use an event loop
69loop for that (such as the L<Event|Event> module): IO::AIO will naturally 71for that (such as the L<Event|Event> module): IO::AIO will naturally fit
70fit into such an event loop itself. 72into such an event loop itself.
71 73
72In this version, a number of threads are started that execute your 74In this version, a number of threads are started that execute your
73requests and signal their completion. You don't need thread support 75requests and signal their completion. You don't need thread support
74in perl, and the threads created by this module will not be visible 76in perl, and the threads created by this module will not be visible
75to perl. In the future, this module might make use of the native aio 77to perl. In the future, this module might make use of the native aio
98 poll => 'r', 100 poll => 'r',
99 cb => \&IO::AIO::poll_cb); 101 cb => \&IO::AIO::poll_cb);
100 102
101 # queue the request to open /etc/passwd 103 # queue the request to open /etc/passwd
102 aio_open "/etc/passwd", O_RDONLY, 0, sub { 104 aio_open "/etc/passwd", O_RDONLY, 0, sub {
103 my $fh = $_[0] 105 my $fh = shift
104 or die "error while opening: $!"; 106 or die "error while opening: $!";
105 107
106 # stat'ing filehandles is generally non-blocking 108 # stat'ing filehandles is generally non-blocking
107 my $size = -s $fh; 109 my $size = -s $fh;
108 110
176Request has reached the end of its lifetime and holds no resources anymore 178Request has reached the end of its lifetime and holds no resources anymore
177(except possibly for the Perl object, but its connection to the actual 179(except possibly for the Perl object, but its connection to the actual
178aio request is severed and calling its methods will either do nothing or 180aio request is severed and calling its methods will either do nothing or
179result in a runtime error). 181result in a runtime error).
180 182
183=back
184
181=cut 185=cut
182 186
183package IO::AIO; 187package IO::AIO;
184 188
185no warnings; 189no warnings;
186use strict 'vars'; 190use strict 'vars';
187 191
188use base 'Exporter'; 192use base 'Exporter';
189 193
190BEGIN { 194BEGIN {
191 our $VERSION = '2.1'; 195 our $VERSION = '2.33';
192 196
193 our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat 197 our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat
194 aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink 198 aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink
195 aio_fsync aio_fdatasync aio_readahead aio_rename aio_link aio_move 199 aio_readlink aio_fsync aio_fdatasync aio_readahead aio_rename aio_link
196 aio_copy aio_group aio_nop aio_mknod); 200 aio_move aio_copy aio_group aio_nop aio_mknod aio_load aio_rmtree aio_mkdir);
197 our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice)); 201 our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice aio_block));
198 our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush 202 our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush
199 min_parallel max_parallel max_idle 203 min_parallel max_parallel max_idle
200 nreqs nready npending nthreads 204 nreqs nready npending nthreads
201 max_poll_time max_poll_reqs); 205 max_poll_time max_poll_reqs);
202 206
286list. They are the same as used by C<sysopen>. 290list. They are the same as used by C<sysopen>.
287 291
288Likewise, C<$mode> specifies the mode of the newly created file, if it 292Likewise, C<$mode> specifies the mode of the newly created file, if it
289didn't exist and C<O_CREAT> has been given, just like perl's C<sysopen>, 293didn't exist and C<O_CREAT> has been given, just like perl's C<sysopen>,
290except that it is mandatory (i.e. use C<0> if you don't create new files, 294except that it is mandatory (i.e. use C<0> if you don't create new files,
291and C<0666> or C<0777> if you do). 295and C<0666> or C<0777> if you do). Note that the C<$mode> will be modified
296by the umask in effect then the request is being executed, so better never
297change the umask.
292 298
293Example: 299Example:
294 300
295 aio_open "/etc/passwd", O_RDONLY, 0, sub { 301 aio_open "/etc/passwd", O_RDONLY, 0, sub {
296 if ($_[0]) { 302 if ($_[0]) {
415=item aio_symlink $srcpath, $dstpath, $callback->($status) 421=item aio_symlink $srcpath, $dstpath, $callback->($status)
416 422
417Asynchronously create a new symbolic link to the existing object at C<$srcpath> at 423Asynchronously create a new symbolic link to the existing object at C<$srcpath> at
418the path C<$dstpath> and call the callback with the result code. 424the path C<$dstpath> and call the callback with the result code.
419 425
426=item aio_readlink $path, $callback->($link)
427
428Asynchronously read the symlink specified by C<$path> and pass it to
429the callback. If an error occurs, nothing or undef gets passed to the
430callback.
431
420=item aio_rename $srcpath, $dstpath, $callback->($status) 432=item aio_rename $srcpath, $dstpath, $callback->($status)
421 433
422Asynchronously rename the object at C<$srcpath> to C<$dstpath>, just as 434Asynchronously rename the object at C<$srcpath> to C<$dstpath>, just as
423rename(2) and call the callback with the result code. 435rename(2) and call the callback with the result code.
436
437=item aio_mkdir $pathname, $mode, $callback->($status)
438
439Asynchronously mkdir (create) a directory and call the callback with
440the result code. C<$mode> will be modified by the umask at the time the
441request is executed, so do not change your umask.
424 442
425=item aio_rmdir $pathname, $callback->($status) 443=item aio_rmdir $pathname, $callback->($status)
426 444
427Asynchronously rmdir (delete) a directory and call the callback with the 445Asynchronously rmdir (delete) a directory and call the callback with the
428result code. 446result code.
433directory (i.e. opendir + readdir + closedir). The entries will not be 451directory (i.e. opendir + readdir + closedir). The entries will not be
434sorted, and will B<NOT> include the C<.> and C<..> entries. 452sorted, and will B<NOT> include the C<.> and C<..> entries.
435 453
436The callback a single argument which is either C<undef> or an array-ref 454The callback a single argument which is either C<undef> or an array-ref
437with the filenames. 455with the filenames.
456
457=item aio_load $path, $data, $callback->($status)
458
459This is a composite request that tries to fully load the given file into
460memory. Status is the same as with aio_read.
461
462=cut
463
464sub aio_load($$;$) {
465 aio_block {
466 my ($path, undef, $cb) = @_;
467 my $data = \$_[1];
468
469 my $pri = aioreq_pri;
470 my $grp = aio_group $cb;
471
472 aioreq_pri $pri;
473 add $grp aio_open $path, O_RDONLY, 0, sub {
474 my $fh = shift
475 or return $grp->result (-1);
476
477 aioreq_pri $pri;
478 add $grp aio_read $fh, 0, (-s $fh), $$data, 0, sub {
479 $grp->result ($_[0]);
480 };
481 };
482
483 $grp
484 }
485}
438 486
439=item aio_copy $srcpath, $dstpath, $callback->($status) 487=item aio_copy $srcpath, $dstpath, $callback->($status)
440 488
441Try to copy the I<file> (directories not supported as either source or 489Try to copy the I<file> (directories not supported as either source or
442destination) from C<$srcpath> to C<$dstpath> and call the callback with 490destination) from C<$srcpath> to C<$dstpath> and call the callback with
452errors are being ignored. 500errors are being ignored.
453 501
454=cut 502=cut
455 503
456sub aio_copy($$;$) { 504sub aio_copy($$;$) {
505 aio_block {
457 my ($src, $dst, $cb) = @_; 506 my ($src, $dst, $cb) = @_;
458 507
459 my $pri = aioreq_pri; 508 my $pri = aioreq_pri;
460 my $grp = aio_group $cb; 509 my $grp = aio_group $cb;
461 510
462 aioreq_pri $pri; 511 aioreq_pri $pri;
463 add $grp aio_open $src, O_RDONLY, 0, sub { 512 add $grp aio_open $src, O_RDONLY, 0, sub {
464 if (my $src_fh = $_[0]) { 513 if (my $src_fh = $_[0]) {
465 my @stat = stat $src_fh; 514 my @stat = stat $src_fh;
466 515
467 aioreq_pri $pri; 516 aioreq_pri $pri;
468 add $grp aio_open $dst, O_CREAT | O_WRONLY | O_TRUNC, 0200, sub { 517 add $grp aio_open $dst, O_CREAT | O_WRONLY | O_TRUNC, 0200, sub {
469 if (my $dst_fh = $_[0]) { 518 if (my $dst_fh = $_[0]) {
470 aioreq_pri $pri; 519 aioreq_pri $pri;
471 add $grp aio_sendfile $dst_fh, $src_fh, 0, $stat[7], sub { 520 add $grp aio_sendfile $dst_fh, $src_fh, 0, $stat[7], sub {
472 if ($_[0] == $stat[7]) { 521 if ($_[0] == $stat[7]) {
473 $grp->result (0); 522 $grp->result (0);
474 close $src_fh; 523 close $src_fh;
475 524
476 # those should not normally block. should. should. 525 # those should not normally block. should. should.
477 utime $stat[8], $stat[9], $dst; 526 utime $stat[8], $stat[9], $dst;
478 chmod $stat[2] & 07777, $dst_fh; 527 chmod $stat[2] & 07777, $dst_fh;
479 chown $stat[4], $stat[5], $dst_fh; 528 chown $stat[4], $stat[5], $dst_fh;
480 close $dst_fh; 529 close $dst_fh;
481 } else { 530 } else {
482 $grp->result (-1); 531 $grp->result (-1);
483 close $src_fh; 532 close $src_fh;
484 close $dst_fh; 533 close $dst_fh;
485 534
486 aioreq $pri; 535 aioreq $pri;
487 add $grp aio_unlink $dst; 536 add $grp aio_unlink $dst;
537 }
488 } 538 };
539 } else {
540 $grp->result (-1);
489 }; 541 }
490 } else {
491 $grp->result (-1);
492 } 542 },
543
544 } else {
545 $grp->result (-1);
493 }, 546 }
494
495 } else {
496 $grp->result (-1);
497 } 547 };
548
549 $grp
498 }; 550 }
499
500 $grp
501} 551}
502 552
503=item aio_move $srcpath, $dstpath, $callback->($status) 553=item aio_move $srcpath, $dstpath, $callback->($status)
504 554
505Try to move the I<file> (directories not supported as either source or 555Try to move the I<file> (directories not supported as either source or
511that is successful, unlinking the C<$srcpath>. 561that is successful, unlinking the C<$srcpath>.
512 562
513=cut 563=cut
514 564
515sub aio_move($$;$) { 565sub aio_move($$;$) {
566 aio_block {
516 my ($src, $dst, $cb) = @_; 567 my ($src, $dst, $cb) = @_;
517 568
518 my $pri = aioreq_pri; 569 my $pri = aioreq_pri;
519 my $grp = aio_group $cb; 570 my $grp = aio_group $cb;
520 571
521 aioreq_pri $pri; 572 aioreq_pri $pri;
522 add $grp aio_rename $src, $dst, sub { 573 add $grp aio_rename $src, $dst, sub {
523 if ($_[0] && $! == EXDEV) { 574 if ($_[0] && $! == EXDEV) {
524 aioreq_pri $pri; 575 aioreq_pri $pri;
525 add $grp aio_copy $src, $dst, sub { 576 add $grp aio_copy $src, $dst, sub {
577 $grp->result ($_[0]);
578
579 if (!$_[0]) {
580 aioreq_pri $pri;
581 add $grp aio_unlink $src;
582 }
583 };
584 } else {
526 $grp->result ($_[0]); 585 $grp->result ($_[0]);
527
528 if (!$_[0]) {
529 aioreq_pri $pri;
530 add $grp aio_unlink $src;
531 }
532 }; 586 }
533 } else {
534 $grp->result ($_[0]);
535 } 587 };
588
589 $grp
536 }; 590 }
537
538 $grp
539} 591}
540 592
541=item aio_scandir $path, $maxreq, $callback->($dirs, $nondirs) 593=item aio_scandir $path, $maxreq, $callback->($dirs, $nondirs)
542 594
543Scans a directory (similar to C<aio_readdir>) but additionally tries to 595Scans a directory (similar to C<aio_readdir>) but additionally tries to
590as those tend to return 0 or 1 as link counts, which disables the 642as those tend to return 0 or 1 as link counts, which disables the
591directory counting heuristic. 643directory counting heuristic.
592 644
593=cut 645=cut
594 646
595sub aio_scandir($$$) { 647sub aio_scandir($$;$) {
648 aio_block {
596 my ($path, $maxreq, $cb) = @_; 649 my ($path, $maxreq, $cb) = @_;
597 650
598 my $pri = aioreq_pri; 651 my $pri = aioreq_pri;
599 652
600 my $grp = aio_group $cb; 653 my $grp = aio_group $cb;
601 654
602 $maxreq = 4 if $maxreq <= 0; 655 $maxreq = 4 if $maxreq <= 0;
603 656
604 # stat once 657 # stat once
605 aioreq_pri $pri;
606 add $grp aio_stat $path, sub {
607 return $grp->result () if $_[0];
608 my $now = time;
609 my $hash1 = join ":", (stat _)[0,1,3,7,9];
610
611 # read the directory entries
612 aioreq_pri $pri; 658 aioreq_pri $pri;
613 add $grp aio_readdir $path, sub { 659 add $grp aio_stat $path, sub {
614 my $entries = shift
615 or return $grp->result (); 660 return $grp->result () if $_[0];
661 my $now = time;
662 my $hash1 = join ":", (stat _)[0,1,3,7,9];
616 663
617 # stat the dir another time 664 # read the directory entries
618 aioreq_pri $pri; 665 aioreq_pri $pri;
666 add $grp aio_readdir $path, sub {
667 my $entries = shift
668 or return $grp->result ();
669
670 # stat the dir another time
671 aioreq_pri $pri;
619 add $grp aio_stat $path, sub { 672 add $grp aio_stat $path, sub {
620 my $hash2 = join ":", (stat _)[0,1,3,7,9]; 673 my $hash2 = join ":", (stat _)[0,1,3,7,9];
621 674
622 my $ndirs; 675 my $ndirs;
623 676
624 # take the slow route if anything looks fishy 677 # take the slow route if anything looks fishy
625 if ($hash1 ne $hash2 or (stat _)[9] == $now) { 678 if ($hash1 ne $hash2 or (stat _)[9] == $now) {
626 $ndirs = -1; 679 $ndirs = -1;
627 } else { 680 } else {
628 # if nlink == 2, we are finished 681 # if nlink == 2, we are finished
629 # on non-posix-fs's, we rely on nlink < 2 682 # on non-posix-fs's, we rely on nlink < 2
630 $ndirs = (stat _)[3] - 2 683 $ndirs = (stat _)[3] - 2
631 or return $grp->result ([], $entries); 684 or return $grp->result ([], $entries);
632 } 685 }
633 686
634 # sort into likely dirs and likely nondirs 687 # sort into likely dirs and likely nondirs
635 # dirs == files without ".", short entries first 688 # dirs == files without ".", short entries first
636 $entries = [map $_->[0], 689 $entries = [map $_->[0],
637 sort { $b->[1] cmp $a->[1] } 690 sort { $b->[1] cmp $a->[1] }
638 map [$_, sprintf "%s%04d", (/.\./ ? "1" : "0"), length], 691 map [$_, sprintf "%s%04d", (/.\./ ? "1" : "0"), length],
639 @$entries]; 692 @$entries];
640 693
641 my (@dirs, @nondirs); 694 my (@dirs, @nondirs);
642 695
643 my $statgrp = add $grp aio_group sub { 696 my $statgrp = add $grp aio_group sub {
644 $grp->result (\@dirs, \@nondirs); 697 $grp->result (\@dirs, \@nondirs);
645 }; 698 };
646 699
647 limit $statgrp $maxreq; 700 limit $statgrp $maxreq;
648 feed $statgrp sub { 701 feed $statgrp sub {
649 return unless @$entries; 702 return unless @$entries;
650 my $entry = pop @$entries; 703 my $entry = pop @$entries;
651 704
652 aioreq_pri $pri; 705 aioreq_pri $pri;
653 add $statgrp aio_stat "$path/$entry/.", sub { 706 add $statgrp aio_stat "$path/$entry/.", sub {
654 if ($_[0] < 0) { 707 if ($_[0] < 0) {
655 push @nondirs, $entry; 708 push @nondirs, $entry;
656 } else { 709 } else {
657 # need to check for real directory 710 # need to check for real directory
658 aioreq_pri $pri; 711 aioreq_pri $pri;
659 add $statgrp aio_lstat "$path/$entry", sub { 712 add $statgrp aio_lstat "$path/$entry", sub {
660 if (-d _) { 713 if (-d _) {
661 push @dirs, $entry; 714 push @dirs, $entry;
662 715
663 unless (--$ndirs) { 716 unless (--$ndirs) {
664 push @nondirs, @$entries; 717 push @nondirs, @$entries;
665 feed $statgrp; 718 feed $statgrp;
719 }
720 } else {
721 push @nondirs, $entry;
666 } 722 }
667 } else {
668 push @nondirs, $entry;
669 } 723 }
670 } 724 }
671 } 725 };
672 }; 726 };
673 }; 727 };
674 }; 728 };
675 }; 729 };
730
731 $grp
676 }; 732 }
733}
677 734
735=item aio_rmtree $path, $callback->($status)
736
737Delete a directory tree starting (and including) C<$path>, return the
738status of the final C<rmdir> only. This is a composite request that
739uses C<aio_scandir> to recurse into and rmdir directories, and unlink
740everything else.
741
742=cut
743
744sub aio_rmtree;
745sub aio_rmtree($;$) {
746 aio_block {
747 my ($path, $cb) = @_;
748
749 my $pri = aioreq_pri;
750 my $grp = aio_group $cb;
751
752 aioreq_pri $pri;
753 add $grp aio_scandir $path, 0, sub {
754 my ($dirs, $nondirs) = @_;
755
756 my $dirgrp = aio_group sub {
757 add $grp aio_rmdir $path, sub {
758 $grp->result ($_[0]);
759 };
760 };
761
762 (aioreq_pri $pri), add $dirgrp aio_rmtree "$path/$_" for @$dirs;
763 (aioreq_pri $pri), add $dirgrp aio_unlink "$path/$_" for @$nondirs;
764
765 add $grp $dirgrp;
766 };
767
678 $grp 768 $grp
769 }
679} 770}
680 771
681=item aio_fsync $fh, $callback->($status) 772=item aio_fsync $fh, $callback->($status)
682 773
683Asynchronously call fsync on the given filehandle and call the callback 774Asynchronously call fsync on the given filehandle and call the callback
937that are being processed by C<IO::AIO::poll_cb> in one call, respectively 1028that are being processed by C<IO::AIO::poll_cb> in one call, respectively
938the maximum amount of time (default C<0>, meaning infinity) spent in 1029the maximum amount of time (default C<0>, meaning infinity) spent in
939C<IO::AIO::poll_cb> to process requests (more correctly the mininum amount 1030C<IO::AIO::poll_cb> to process requests (more correctly the mininum amount
940of time C<poll_cb> is allowed to use). 1031of time C<poll_cb> is allowed to use).
941 1032
1033Setting C<max_poll_time> to a non-zero value creates an overhead of one
1034syscall per request processed, which is not normally a problem unless your
1035callbacks are really really fast or your OS is really really slow (I am
1036not mentioning Solaris here). Using C<max_poll_reqs> incurs no overhead.
1037
942Setting these is useful if you want to ensure some level of 1038Setting these is useful if you want to ensure some level of
943interactiveness when perl is not fast enough to process all requests in 1039interactiveness when perl is not fast enough to process all requests in
944time. 1040time.
945 1041
946For interactive programs, values such as C<0.01> to C<0.1> should be fine. 1042For interactive programs, values such as C<0.01> to C<0.1> should be fine.
947 1043
948Example: Install an Event watcher that automatically calls 1044Example: Install an Event watcher that automatically calls
949IO::AIO::poll_some with low priority, to ensure that other parts of the 1045IO::AIO::poll_cb with low priority, to ensure that other parts of the
950program get the CPU sometimes even under high AIO load. 1046program get the CPU sometimes even under high AIO load.
951 1047
952 # try not to spend much more than 0.1s in poll_cb 1048 # try not to spend much more than 0.1s in poll_cb
953 IO::AIO::max_poll_time 0.1; 1049 IO::AIO::max_poll_time 0.1;
954 1050
957 poll => 'r', nice => 1, 1053 poll => 'r', nice => 1,
958 cb => &IO::AIO::poll_cb); 1054 cb => &IO::AIO::poll_cb);
959 1055
960=item IO::AIO::poll_wait 1056=item IO::AIO::poll_wait
961 1057
1058If there are any outstanding requests and none of them in the result
962Wait till the result filehandle becomes ready for reading (simply does a 1059phase, wait till the result filehandle becomes ready for reading (simply
963C<select> on the filehandle. This is useful if you want to synchronously 1060does a C<select> on the filehandle. This is useful if you want to
964wait for some requests to finish). 1061synchronously wait for some requests to finish).
965 1062
966See C<nreqs> for an example. 1063See C<nreqs> for an example.
967 1064
968=item IO::AIO::poll 1065=item IO::AIO::poll
969 1066
970Waits until some requests have been handled. 1067Waits until some requests have been handled.
971 1068
1069Returns the number of requests processed, but is otherwise strictly
972Strictly equivalent to: 1070equivalent to:
973 1071
974 IO::AIO::poll_wait, IO::AIO::poll_cb 1072 IO::AIO::poll_wait, IO::AIO::poll_cb
975 if IO::AIO::nreqs;
976 1073
977=item IO::AIO::flush 1074=item IO::AIO::flush
978 1075
979Wait till all outstanding AIO requests have been handled. 1076Wait till all outstanding AIO requests have been handled.
980 1077
981Strictly equivalent to: 1078Strictly equivalent to:
982 1079
983 IO::AIO::poll_wait, IO::AIO::poll_cb 1080 IO::AIO::poll_wait, IO::AIO::poll_cb
984 while IO::AIO::nreqs; 1081 while IO::AIO::nreqs;
985 1082
1083=back
1084
986=head3 CONTROLLING THE NUMBER OF THREADS 1085=head3 CONTROLLING THE NUMBER OF THREADS
1086
1087=over
987 1088
988=item IO::AIO::min_parallel $nthreads 1089=item IO::AIO::min_parallel $nthreads
989 1090
990Set the minimum number of AIO threads to C<$nthreads>. The current 1091Set the minimum number of AIO threads to C<$nthreads>. The current
991default is C<8>, which means eight asynchronous operations can execute 1092default is C<8>, which means eight asynchronous operations can execute
1050 1151
1051You can still queue as many requests as you want. Therefore, 1152You can still queue as many requests as you want. Therefore,
1052C<max_oustsanding> is mainly useful in simple scripts (with low values) or 1153C<max_oustsanding> is mainly useful in simple scripts (with low values) or
1053as a stop gap to shield against fatal memory overflow (with large values). 1154as a stop gap to shield against fatal memory overflow (with large values).
1054 1155
1156=back
1157
1055=head3 STATISTICAL INFORMATION 1158=head3 STATISTICAL INFORMATION
1159
1160=over
1056 1161
1057=item IO::AIO::nreqs 1162=item IO::AIO::nreqs
1058 1163
1059Returns the number of requests currently in the ready, execute or pending 1164Returns the number of requests currently in the ready, execute or pending
1060states (i.e. for which their callback has not been invoked yet). 1165states (i.e. for which their callback has not been invoked yet).
1094 *$sym 1199 *$sym
1095} 1200}
1096 1201
1097min_parallel 8; 1202min_parallel 8;
1098 1203
1099END { 1204END { flush }
1100 min_parallel 1;
1101 flush;
1102};
1103 1205
11041; 12061;
1105 1207
1106=head2 FORK BEHAVIOUR 1208=head2 FORK BEHAVIOUR
1107 1209

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines