From: Jarkko Hietaniemi Date: Sun, 12 May 2002 13:50:20 +0000 (+0000) Subject: As suggested by Dave Mitchell, adding yield()s at X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=da32f63e54ca956472e919d15f2271b9494ad04e;p=p5sagit%2Fp5-mst-13.2.git As suggested by Dave Mitchell, adding yield()s at appropriate spots helps non-preemptive thread implementations, like the GNU pth. Tested at NetBSD by Martin Weber . p4raw-id: //depot/perl@16555 --- diff --git a/ext/threads/t/basic.t b/ext/threads/t/basic.t index eca5c97..fa9a655 100755 --- a/ext/threads/t/basic.t +++ b/ext/threads/t/basic.t @@ -78,6 +78,7 @@ sub test4 { ok(6,1,"Detach test") } my $thread1 = threads->create('test4'); $thread1->detach(); +threads->yield; # help out non-preemptive thread implementations sleep 2; ok(7,1,"Detach test"); diff --git a/ext/threads/t/list.t b/ext/threads/t/list.t index e5929ed..f0995a1 100644 --- a/ext/threads/t/list.t +++ b/ext/threads/t/list.t @@ -47,6 +47,7 @@ $thread->join(); ok(5, scalar @{[threads->list]} == 1); $thread = threads->create(sub { ok(6, threads->self == (threads->list)[1])}); +threads->yield; # help out non-preemptive thread implementations sleep 1; ok(7, $thread == (threads->list)[1]); $thread->join(); diff --git a/ext/threads/t/thread.t b/ext/threads/t/thread.t index 85bf2cd..435f3bd 100644 --- a/ext/threads/t/thread.t +++ b/ext/threads/t/thread.t @@ -54,6 +54,7 @@ sub dorecurse { { # test that sleep lets other thread run my $t = threads->new(\&dorecurse, "ok 11\n"); + threads->yield; # help out non-preemptive thread implementations sleep 1; print "ok 12\n"; $t->join();