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

Comparing Coro/t/15_semaphore.t (file contents):
Revision 1.1 by root, Sat Nov 15 06:26:52 2008 UTC vs.
Revision 1.2 by root, Sun Nov 16 09:43:18 2008 UTC

1$|=1; 1$|=1;
2print "1..1\n"; 2print "1..2\n";
3 3
4use Coro; 4use Coro;
5use Coro::Semaphore; 5use Coro::Semaphore;
6 6
7my $sem = new Coro::Semaphore 2; 7my $sem = new Coro::Semaphore 2;
28 } 28 }
29 } 29 }
30 } 1..15 30 } 1..15
31; 31;
32 32
33print $counter == 750 ? "" : "not ", "ok 1 # $counter\n" 33print $counter == 750 ? "" : "not ", "ok 1 # $counter\n";
34 34
35{
36 my $sem = new Coro::Semaphore 0;
37
38 $as1 = async {
39 my $g = $sem->guard;
40 print "not ok 2\n";
41 };
42
43 $as2 = async {
44 my $g = $sem->guard;
45 print "ok 2\n";
46 };
47
48 cede;
49
50 $sem->up; # wake up as1
51 $as1->cancel; # destroy as1 before it could ->guard
52 $as1->join;
53 $as2->join;
54}
55
56

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines