ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/t/16_signal.t
(Generate patch)

Comparing Coro/t/16_signal.t (file contents):
Revision 1.1 by root, Wed Nov 19 00:06:55 2008 UTC vs.
Revision 1.3 by root, Wed Jun 24 02:52:38 2009 UTC

1$|=1; 1$|=1;
2print "1..7\n"; 2print "1..18\n";
3 3
4no warnings; 4no warnings;
5use Coro; 5use Coro;
6use Coro::Signal; 6use Coro::Signal;
7 7
8{ 8{
9 my $sig = new Coro::Signal; 9 my $sig = new Coro::Signal;
10 10
11 $as1 = async { 11 $as1 = async {
12 my $g = $sig->wait; 12 my $g = $sig->wait;
13 print "ok 2\n"; 13 print "ok 3\n";
14 }; 14 };
15 15
16 $as2 = async { 16 $as2 = async {
17 my $g = $sig->wait; 17 my $g = $sig->wait;
18 print "ok 4\n"; 18 print "ok 4\n";
19 }; 19 };
20 20
21 cede; 21 cede; # put 1, 2 in wait q
22
23 $sig->send;
24 22
25 $as3 = async { 23 $as3 = async {
26 my $g = $sig->wait; 24 my $g = $sig->wait;
27 print "ok 5\n"; 25 print "ok 2\n";
28 }; 26 };
29
30 $sig->send;
31 27
32 $as4 = async { 28 $as4 = async {
33 my $g = $sig->wait; 29 my $g = $sig->wait;
34 print "ok 6\n"; 30 print "ok 6\n";
35 }; 31 };
36 32
37 $sig->send; 33 $as5 = async {
34 my $g = $sig->wait;
35 print "ok 9\n";
36 };
37
38 $sig->send; # ready 1
39 $sig->send; # ready 2
40 $sig->send; # remember
38 41
39 print +(Coro::Semaphore::count $sig) == 1 ? "" : "not ", "ok 1\n"; 42 print +(Coro::Semaphore::count $sig) == 1 ? "" : "not ", "ok 1\n";
40 43
41 cede; 44 cede; # execute 3 (already ready, no contention), 1, 2
42 45
43 print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 3\n"; 46 print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 5\n";
44 47
45 $sig->send; 48 $sig->send;
46 cede; 49 cede;
47 50
48 print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 5\n"; 51 print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 7\n";
49 52
50 $sig->broadcast; 53 $sig->broadcast;
51 print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 6\n"; 54 print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 8\n";
52 cede; 55 cede;
53 56
57 $sig->wait (sub { print "ok 12\n" });
58 print "ok 10\n";
59
60 print "ok 11\n";
61
62 $sig->send;
63 print "ok 13\n";
64 cede;
65
66 print "ok 14\n";
67 $sig->send;
68 print "ok 15\n";
69
70 $sig->wait (sub { print "ok 16\n" });
71 print "ok 17\n";
72
54 print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 7\n"; 73 print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 18\n";
55} 74}
56 75

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines