1 | $|=1; |
1 | $|=1; |
2 | print "1..1\n"; |
2 | print "1..2\n"; |
3 | |
3 | |
4 | use Coro; |
4 | use Coro; |
5 | use Coro::Semaphore; |
5 | use Coro::Semaphore; |
6 | |
6 | |
7 | my $sem = new Coro::Semaphore 2; |
7 | my $sem = new Coro::Semaphore 2; |
… | |
… | |
28 | } |
28 | } |
29 | } |
29 | } |
30 | } 1..15 |
30 | } 1..15 |
31 | ; |
31 | ; |
32 | |
32 | |
33 | print $counter == 750 ? "" : "not ", "ok 1 # $counter\n" |
33 | print $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 | |