Makes list skip the main thread.
Artur Bergman [Wed, 10 Jul 2002 17:59:19 +0000 (17:59 +0000)]
p4raw-id: //depot/perl@17466

ext/threads/t/list.t
ext/threads/threads.xs

index f0995a1..60bf209 100644 (file)
@@ -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);
index 59e3597..88aaf0e 100755 (executable)
@@ -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);
 }