1 |
$|=1; |
2 |
print "1..7\n"; |
3 |
|
4 |
no warnings; |
5 |
use Coro; |
6 |
use Coro::Signal; |
7 |
|
8 |
{ |
9 |
my $sig = new Coro::Signal; |
10 |
|
11 |
$as1 = async { |
12 |
my $g = $sig->wait; |
13 |
print "ok 2\n"; |
14 |
}; |
15 |
|
16 |
$as2 = async { |
17 |
my $g = $sig->wait; |
18 |
print "ok 4\n"; |
19 |
}; |
20 |
|
21 |
cede; |
22 |
|
23 |
$sig->send; |
24 |
|
25 |
$as3 = async { |
26 |
my $g = $sig->wait; |
27 |
print "ok 5\n"; |
28 |
}; |
29 |
|
30 |
$sig->send; |
31 |
|
32 |
$as4 = async { |
33 |
my $g = $sig->wait; |
34 |
print "ok 6\n"; |
35 |
}; |
36 |
|
37 |
$sig->send; |
38 |
|
39 |
print +(Coro::Semaphore::count $sig) == 1 ? "" : "not ", "ok 1\n"; |
40 |
|
41 |
cede; |
42 |
|
43 |
print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 3\n"; |
44 |
|
45 |
$sig->send; |
46 |
cede; |
47 |
|
48 |
print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 5\n"; |
49 |
|
50 |
$sig->broadcast; |
51 |
print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 6\n"; |
52 |
cede; |
53 |
|
54 |
print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 7\n"; |
55 |
} |
56 |
|