Commit | Line | Data |
3dbf27b4 |
1 | BEGIN { |
2 | chdir 't' if -d 't'; |
3 | @INC = '../lib'; |
4 | require Config; import Config; |
5 | unless ($Config{'useithreads'}) { |
6 | print "1..0 # Skip: no useithreads\n"; |
7 | exit 0; |
8 | } |
9 | } |
10 | |
11 | use ExtUtils::testlib; |
12 | use strict; |
13 | BEGIN { print "1..64\n" }; |
14 | use threads; |
15 | |
16 | |
17 | print "ok 1\n"; |
18 | |
19 | |
20 | |
21 | |
22 | sub ok { |
23 | my ($id, $ok, $name) = @_; |
24 | |
25 | # You have to do it this way or VMS will get confused. |
26 | print $ok ? "ok $id - $name\n" : "not ok $id - $name\n"; |
27 | |
28 | printf "# Failed test at line %d\n", (caller)[2] unless $ok; |
29 | |
30 | return $ok; |
31 | } |
32 | |
33 | |
34 | ok(2,1,""); |
35 | |
36 | |
37 | my @threads; |
38 | for(3..33) { |
39 | ok($_,1,"Multiple thread test"); |
40 | push @threads ,threads->create(sub { my $i = shift; for(1..500000) { $i++}},$_); |
41 | } |
42 | |
43 | my $i = 34; |
44 | for(@threads) { |
45 | $_->join; |
46 | ok($i++,1,"Thread joined"); |
47 | } |
48 | |