ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/t/16_signal.t
Revision: 1.2
Committed: Wed Nov 19 02:07:48 2008 UTC (15 years, 7 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-5_131, rel-6_13, rel-5_11, rel-5_12, rel-5_14, rel-5_132, rel-5_0, rel-5_1
Changes since 1.1: +17 -14 lines
Log Message:
*** empty log message ***

File Contents

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