1 |
root |
1.1 |
$|=1; |
2 |
root |
1.2 |
print "1..10\n"; |
3 |
root |
1.1 |
|
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 |
root |
1.2 |
print "ok 3\n"; |
14 |
root |
1.1 |
}; |
15 |
|
|
|
16 |
|
|
$as2 = async { |
17 |
|
|
my $g = $sig->wait; |
18 |
|
|
print "ok 4\n"; |
19 |
|
|
}; |
20 |
|
|
|
21 |
root |
1.2 |
cede; # put 1, 2 in wait q |
22 |
root |
1.1 |
|
23 |
|
|
$as3 = async { |
24 |
|
|
my $g = $sig->wait; |
25 |
root |
1.2 |
print "ok 2\n"; |
26 |
root |
1.1 |
}; |
27 |
|
|
|
28 |
|
|
$as4 = async { |
29 |
|
|
my $g = $sig->wait; |
30 |
|
|
print "ok 6\n"; |
31 |
|
|
}; |
32 |
|
|
|
33 |
root |
1.2 |
$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 |
41 |
root |
1.1 |
|
42 |
|
|
print +(Coro::Semaphore::count $sig) == 1 ? "" : "not ", "ok 1\n"; |
43 |
|
|
|
44 |
root |
1.2 |
cede; # execute 3 (already ready, no contention), 1, 2 |
45 |
root |
1.1 |
|
46 |
root |
1.2 |
print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 5\n"; |
47 |
root |
1.1 |
|
48 |
|
|
$sig->send; |
49 |
|
|
cede; |
50 |
|
|
|
51 |
root |
1.2 |
print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 7\n"; |
52 |
root |
1.1 |
|
53 |
|
|
$sig->broadcast; |
54 |
root |
1.2 |
print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 8\n"; |
55 |
root |
1.1 |
cede; |
56 |
|
|
|
57 |
root |
1.2 |
print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 10\n"; |
58 |
root |
1.1 |
} |
59 |
|
|
|