use warnings;
use lib 't/lib';
+use VPIT::TestHelpers;
use Thread::Cleanup::TestThreads;
use Test::More 'no_plan';
use Thread::Cleanup;
my %called : shared;
+my $destr : shared;
my %nums : shared;
our $x = -1;
lock %nums;
$nums{$tid};
};
-
is $x, $num, "\$x in destructor of thread $tid";
+
+ my $gd = do {
+ lock $destr;
+ (defined $destr && $destr =~ /\[$tid\]/) ? 1 : undef;
+ };
+ is $gd, undef, "thread $tid destructor fires before global destruction";
+
local $x = $tid;
};
$ran{$tid}++;
}
+ my $immortal = VPIT::TestHelpers::Guard->new(sub {
+ # It seems we can't lock aggregates during global destruction, so we
+ # resort to using a string instead.
+ lock $destr;
+ $destr .= "[$tid]";
+ });
+ $immortal->{self} = $immortal;
+
{
lock %nums;
$nums{$tid} = $y;