]> git.eshelyaron.com Git - emacs.git/commitdiff
the thread_yield return value considers blocked threads too
authorGiuseppe Scrivano <gscrivano@gnu.org>
Thu, 14 Jan 2010 09:32:44 +0000 (10:32 +0100)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Thu, 14 Jan 2010 09:32:44 +0000 (10:32 +0100)
src/thread.c

index f19cb4fc43d6bafbcf137e8430c5bb1dd6842a93..eae83afa3c09e0317ce1b167484ab38a90f4d40a 100644 (file)
@@ -37,7 +37,14 @@ static pthread_t next_thread;
 static void
 thread_schedule ()
 {
-  next_thread = NEXT_THREAD (current_thread)->pthread_id;
+  struct thread_state *it = current_thread;
+  do
+    {
+      it = NEXT_THREAD (it);
+    }
+  while (it->blocked && it != current_thread);
+
+  next_thread = it->pthread_id;
 }
 
 /* Schedule a new thread and block the caller until it is not scheduled
@@ -387,13 +394,7 @@ thread_select (n, rfd, wfd, xfd, tmo)
 int
 other_threads_p (void)
 {
-  int avail = 0;
-  struct thread_state *it = all_threads;
-  for (; it && avail < 2; it = it->next_thread)
-    if (!it->blocked)
-      avail++;
-
-  return avail > 1;
+  return all_threads->next ? 1 : 0;
 }
 
 Lisp_Object