File: 08_async.t

package info (click to toggle)
libev-perl 4.36-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 972 kB
  • sloc: ansic: 7,054; perl: 53; makefile: 10
file content (65 lines) | stat: -rw-r--r-- 1,056 bytes parent folder | download | duplicates (8)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
BEGIN { $| = 1; print "1..13\n"; }

no warnings;
use strict;

use EV;

 {
   my ($a1, $a2, $a3);

   $a3 = EV::async sub {
      print "not ok 1\n";
   };
   $a2 = EV::async sub {
      print "ok 5\n";
      $a1->cb (sub {
         print "ok 6\n";
         EV::break;
      });
      $a1->send;
   };
   $a1 = EV::async sub {
      print $a1->async_pending ? "not " : "", "ok 4\n";
      $a2->send;
   };

   print $a1->async_pending ? "not " : "", "ok 1\n";
   $a1->send;
   print $a1->async_pending ? "" : "not ", "ok 2\n";
   $a1->send;
   $a1->send;
   print "ok 3\n";
   EV::run;
   print "ok 7\n";
}

{
   my $l = new EV::Loop;
   my ($a1, $a2, $a3);

   $a3 = $l->async (sub {
      print "not ok 8\n";
   });
   $a2 = $l->async (sub {
      print "ok 11\n";
      $a1->cb (sub {
         print "ok 12\n";
         $l->break;
      });
      $a1->send;
   });
   $a1 = $l->async (sub {
      print "ok 10\n";
      $a2->send;
   });

   print "ok 8\n";
   $a1->send;
   $a1->send;
   $a1->send;
   print "ok 9\n";
   $l->run;
   print "ok 13\n";
}