From: Artur Bergman Date: Wed, 10 Jul 2002 17:59:19 +0000 (+0000) Subject: Makes list skip the main thread. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5eb9fe8fe9c9104d4fe0d9127fe7389780f8a479;p=p5sagit%2Fp5-mst-13.2.git Makes list skip the main thread. p4raw-id: //depot/perl@17466 --- diff --git a/ext/threads/t/list.t b/ext/threads/t/list.t index f0995a1..60bf209 100644 --- a/ext/threads/t/list.t +++ b/ext/threads/t/list.t @@ -34,21 +34,21 @@ sub ok { return $ok; } +ok(2, scalar @{[threads->list]} == 0); -ok(2, threads->self == (threads->list)[0]); threads->create(sub {})->join(); -ok(3, scalar @{[threads->list]} == 1); +ok(3, scalar @{[threads->list]} == 0); my $thread = threads->create(sub {}); -ok(4, scalar @{[threads->list]} == 2); +ok(4, scalar @{[threads->list]} == 1); $thread->join(); -ok(5, scalar @{[threads->list]} == 1); +ok(5, scalar @{[threads->list]} == 0); -$thread = threads->create(sub { ok(6, threads->self == (threads->list)[1])}); +$thread = threads->create(sub { ok(6, threads->self == (threads->list)[0])}); threads->yield; # help out non-preemptive thread implementations sleep 1; -ok(7, $thread == (threads->list)[1]); +ok(7, $thread == (threads->list)[0]); $thread->join(); -ok(8, scalar @{[threads->list]} == 1); +ok(8, scalar @{[threads->list]} == 0); diff --git a/ext/threads/threads.xs b/ext/threads/threads.xs index 59e3597..88aaf0e 100755 --- a/ext/threads/threads.xs +++ b/ext/threads/threads.xs @@ -561,15 +561,16 @@ PPCODE: ithread *curr_thread; MUTEX_LOCK(&create_destruct_mutex); curr_thread = threads; - PUSHs( sv_2mortal(ithread_to_SV(aTHX_ NULL, curr_thread, classname, TRUE))); + if(curr_thread->tid != 0) + PUSHs( sv_2mortal(ithread_to_SV(aTHX_ NULL, curr_thread, classname, TRUE))); while(curr_thread) { curr_thread = curr_thread->next; if(curr_thread == threads) break; if(curr_thread->state & PERL_ITHR_DETACHED || - curr_thread->state & PERL_ITHR_JOINED) - continue; - PUSHs( sv_2mortal(ithread_to_SV(aTHX_ NULL, curr_thread, classname, TRUE))); + curr_thread->state & PERL_ITHR_JOINED) + continue; + PUSHs( sv_2mortal(ithread_to_SV(aTHX_ NULL, curr_thread, classname, TRUE))); } MUTEX_UNLOCK(&create_destruct_mutex); }