X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F41-clone.t;h=1bfe6b5b3f5f53add4816fbf4aae2a131e6b936e;hb=75e0226fc114601c5e10d253d55e94e201249151;hp=0e47d3694819bc8c37a75cdfb411854dd7ab4aa6;hpb=65768c73d8cbf0c086f7032b384de17479aef9fe;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/41-clone.t b/t/41-clone.t index 0e47d36..1bfe6b5 100644 --- a/t/41-clone.t +++ b/t/41-clone.t @@ -97,3 +97,45 @@ for my $dispell (1, 0) { } } } + +{ + my @threads; + my $flag : shared = 0; + my $destroyed; + + { + my $wiz = wizard( + set => sub { + my $tid = threads->tid; + pass "set callback called in thread $tid" + }, + free => sub { ++$destroyed }, + ); + + my $var = 123; + cast $var, $wiz; + + @threads = map spawn( + sub { + my $tid = threads->tid; + my $exp = 456 + $tid; + { + lock $flag; + threads::shared::cond_wait($flag) until $flag; + } + $var = $exp; + is $var, $exp, "\$var could be assigned to in thread $tid"; + } + ), 1 .. 5; + } + + is $destroyed, 1, 'wizard is destroyed'; + + { + lock $flag; + $flag = 1; + threads::shared::cond_broadcast($flag); + } + + $_->join for @threads; +}