X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F40-threads.t;h=d2c536eed190a11a0be6ebc4f1c748f5374bfc61;hb=4ae554f588e33ed5ca7d26edd634a03016c1a2d6;hp=0b16c6aeb44acc8e18a4ae81ef2b055acb7d57dd;hpb=40ca1914fff709f777b1da437b0ccb82c4fe5468;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/40-threads.t b/t/40-threads.t index 0b16c6a..d2c536e 100644 --- a/t/40-threads.t +++ b/t/40-threads.t @@ -51,7 +51,7 @@ sub try { } 0 }, - free => sub { ++$destroyed; 0 }, + free => sub { lock $destroyed; ++$destroyed; 0 }, op_info => $op_info }; is($@, '', "wizard in thread $tid doesn't croak"); @@ -87,10 +87,18 @@ sub try { for my $dispell (1, 0) { for my $sig (undef, Variable::Magic::gensig()) { - $destroyed = 0; + { + lock $destroyed; + $destroyed = 0; + } + my @t = map { threads->create(\&try, $dispell, $sig, $_) } (VMG_OP_INFO_NAME) x 2, (VMG_OP_INFO_OBJECT) x 2; $_->join for @t; - is($destroyed, (1 - $dispell) * 4, 'destructors'); + + { + lock $destroyed; + is $destroyed, (1 - $dispell) * 4, 'destructors'; + } } }