Commit | Line | Data |
---|---|---|
13c1b207 | 1 | use warnings; |
2 | ||
89661126 | 3 | BEGIN { |
4 | chdir 't' if -d 't'; | |
b5135157 | 5 | push @INC ,'../lib'; |
89661126 | 6 | require Config; import Config; |
7 | unless ($Config{'useithreads'}) { | |
8 | print "1..0 # Skip: no threads\n"; | |
9 | exit 0; | |
10 | } | |
11 | } | |
cd055192 | 12 | $|++; |
b5135157 | 13 | print "1..5\n"; |
89661126 | 14 | use strict; |
15 | ||
b5135157 | 16 | |
89661126 | 17 | use threads; |
18 | ||
19 | use threads::shared; | |
20 | ||
21 | my $lock : shared; | |
22 | ||
23 | sub foo { | |
24 | lock($lock); | |
b5135157 | 25 | print "ok 1\n"; |
7bdf8c10 | 26 | my $tr2 = threads->create(\&bar); |
89661126 | 27 | cond_wait($lock); |
7bdf8c10 | 28 | $tr2->join(); |
b5135157 | 29 | print "ok 5\n"; |
89661126 | 30 | } |
31 | ||
32 | sub bar { | |
7bdf8c10 | 33 | print "ok 2\n"; |
89661126 | 34 | lock($lock); |
b5135157 | 35 | print "ok 3\n"; |
89661126 | 36 | cond_signal($lock); |
b5135157 | 37 | print "ok 4\n"; |
89661126 | 38 | } |
39 | ||
b5135157 | 40 | my $tr = threads->create(\&foo); |
b5135157 | 41 | $tr->join(); |
89661126 | 42 |