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