summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorArtur Bergman <sky@nanisky.com>2002-07-10 17:59:19 +0000
committerArtur Bergman <sky@nanisky.com>2002-07-10 17:59:19 +0000
commit5eb9fe8fe9c9104d4fe0d9127fe7389780f8a479 (patch)
tree9380968783bef1c6bb0e90eab944fc8812d57bb2 /ext
parent55c0ed8ce52f5a0c9efbea1259b92e86214922f8 (diff)
downloadperl-5eb9fe8fe9c9104d4fe0d9127fe7389780f8a479.tar.gz
Makes list skip the main thread.
p4raw-id: //depot/perl@17466
Diffstat (limited to 'ext')
-rw-r--r--ext/threads/t/list.t14
-rwxr-xr-xext/threads/threads.xs9
2 files changed, 12 insertions, 11 deletions
diff --git a/ext/threads/t/list.t b/ext/threads/t/list.t
index f0995a1bc4..60bf20912d 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 59e3597aad..88aaf0eaf7 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);
}