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;
28 defined and diag "Using threads $_" for $threads::VERSION;
29 defined and diag "Using threads::shared $_" for $threads::shared::VERSION;
34 diag 'This will leak some scalars';
45 my ($num, $depth) = @_;
47 return unless $depth > 0;
50 my $thr = threads->create(\&cb, $_, $depth);
51 push @tids, $thr->tid;
60 is $ran{$_}, 1, "thread $_ was run once";
61 is $called{$_}, 1, "thread $_ destructor was called once";
68 my $tid = threads->tid;
78 is $x, $y, "\$x in thread $tid";
81 $_->join for spawn $num, $depth - 1;
86 Thread::Cleanup::register {
87 my $tid = threads->tid;
98 is $x, $num, "\$x in destructor of thread $tid";
102 $_->join for spawn $num, $depth;
106 is $x, -1, '$x in the main thread';