On a real multicpu box the child thread could still be running
Jarkko Hietaniemi [Mon, 9 Jun 2003 20:48:14 +0000 (20:48 +0000)]
when the parent thread was already testing.

p4raw-id: //depot/perl@19731

ext/threads/shared/t/hv_refs.t

index 66df0a6..5ef0c05 100644 (file)
@@ -86,7 +86,13 @@ ok(10, keys %foo == 0, "And make sure we realy have deleted the values");
 }
 {
     my $object : shared = &share({});
-    threads->new(sub { bless $object, 'test1' });
+    lock($object); # so that we can cond_wait
+    threads->new(sub {
+                    lock($object); # so that we can cond_signal
+                    bless $object, 'test1';
+                    cond_signal($object); # so that the parent thread waits
+                });
+    cond_wait($object); # so that the child thread finishes
     ok(15, ref($object) eq 'test1', "blessing does work");
     my %test = (object => $object);
     ok(16, ref($test{object}) eq 'test1', "and some more work");