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