6 use Config qw/%Config/;
9 if (!$Config{useithreads}) {
12 plan(skip_all => 'This perl wasn\'t built to support threads');
25 use Test::More tests => (($num ** ($depth + 1) - 1) / ($num - 1) - 1 ) * (2 + 2) + 1;
29 diag "Using threads $threads::VERSION";
30 diag "Using threads::shared $threads::shared::VERSION";
31 diag 'This will leak some scalars';
42 my ($num, $depth) = @_;
44 return unless $depth > 0;
47 my $thr = threads->create(\&cb, $_, $depth);
48 push @tids, $thr->tid;
57 is $ran{$_}, 1, "thread $_ was run once";
58 is $called{$_}, 1, "thread $_ destructor was called once";
65 my $tid = threads->tid;
75 is $x, $y, "\$x in thread $tid";
78 $_->join for spawn $num, $depth - 1;
83 Thread::Cleanup::register {
84 my $tid = threads->tid;
95 is $x, $num, "\$x in destructor of thread $tid";
99 $_->join for spawn $num, $depth;
103 is $x, -1, '$x in the main thread';