- for my $sig ($wiz_name, getsig($wiz_name), $wiz_obj, getsig($wiz_obj)) {
- $c = 0;
- $destroyed = 0;
-
- my @t = map { threads->create(\&try, $dispell, $sig) } 1 .. 2;
- $_->join for @t;
-
- is($c, 2, "get triggered twice");
- is($destroyed, (1 - $dispell) * 2, 'destructors');
+ for my $wiz ($wiz_name, $wiz_obj) {
+ {
+ lock $c;
+ $c = 0;
+ }
+ {
+ lock $destroyed;
+ $destroyed = 0;
+ }
+
+ my @threads = map spawn(\&try, $dispell, $wiz), 1 .. 2;
+ $_->join for @threads;
+
+ {
+ lock $c;
+ is $c, 2, "get triggered twice";
+ }
+ {
+ lock $destroyed;
+ is $destroyed, (1 - $dispell) * 2, 'destructors';
+ }