8 use Thread::Cleanup::TestThreads;
10 use Test::More 'no_plan';
20 Thread::Cleanup::register {
21 my $tid = threads->tid;
32 is $x, $num, "\$x in destructor of thread $tid";
36 (defined $destr && $destr =~ /\[$tid\]/) ? 1 : undef;
38 is $gd, undef, "thread $tid destructor fires before global destruction";
48 my $tid = threads->tid;
54 my $immortal = VPIT::TestHelpers::Guard->new(sub {
55 # It seems we can't lock aggregates during global destruction, so we
56 # resort to using a string instead.
60 $immortal->{self} = $immortal;
66 is $x, $y, "\$x in thread $tid";
76 my @tids = map $_->tid, @threads;
78 $_->join for @threads;
80 is $x, -1, '$x in the main thread';
83 is $ran{$_}, 1, "thread $_ was run once";
84 is $called{$_}, 1, "thread $_ destructor was called once";