File: 07_feeder.t

package info (click to toggle)
libio-aio-perl 2.4-1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 356 kB
  • ctags: 76
  • sloc: perl: 413; ansic: 97; makefile: 50
file content (34 lines) | stat: -rw-r--r-- 522 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl

use IO::AIO;

print "1..6\n";

my $grp = aio_group sub {
   print "ok 4\n";#d#
};

my $cn1 = 10;
my $cn2 = 0;
my $cn3 = 0;

print "ok 1\n";

limit $grp 5;
$grp->feed (sub {
   return if $cn2 >= 10;
   $cn2++;
   aioreq_pri $cn2;
   (add $grp IO::AIO::aio_busy 0)->cb (sub {
      $cn3++;
   });
});

print $cn2 == 5 ? "" : "not ", "ok 2\n";
print $cn3 == 0 ? "" : "not ", "ok 3\n";

IO::AIO::poll while IO::AIO::nreqs;

print $cn2 == 10 ? "" : "not ", "ok 5\n";
print $cn3 == 10 ? "" : "not ", "ok 6\n";