]> git.eshelyaron.com Git - emacs.git/commitdiff
Rewrite the condition to wake-up the thread that locked the buffer. Also don't try...
authorGiuseppe Scrivano <gscrivano@gnu.org>
Sat, 19 Sep 2009 22:28:05 +0000 (00:28 +0200)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Sat, 19 Sep 2009 22:28:05 +0000 (00:28 +0200)
src/thread.c

index 54cb2ec6d45d215a0228552eb38e56027e5a27c5..036823d52ec334c2c71732c8f0a4fb4cce41c9dd 100644 (file)
@@ -51,11 +51,12 @@ thread_schedule ()
     }                                                           \
 
   /* Try to wake up the thread that is holding the desired buffer.  */
-  if (current_thread->desired_buffer
-      && !EQ (current_thread->desired_buffer->owner, Qnil)
-      && !EQ (current_buffer->owner, current_thread->desired_buffer->owner))
-    CHECK_THREAD (current_thread->desired_buffer->owner,
-                  current_thread->desired_buffer);
+  if (current_thread->desired_buffer)
+    {
+      struct buffer *db = current_thread->desired_buffer;
+      if (!EQ (db->owner, Qnil) && !EQ (db, current_buffer))
+        CHECK_THREAD (XVECTOR (db->owner), db);
+    }
 
   /* A simple round-robin.  We can't just check for it != current_thread
      because current_thread could be already unlinked from all_threads.   */
@@ -160,6 +161,12 @@ thread_acquire_buffer (char *end, void *nb)
       current_buffer->prev_owner = Qnil;
     }
 
+  if (!thread_inhibit_yield_p ())
+    thread_schedule ();
+
+  if (next_thread != current_thread->pthread_id)
+    pthread_cond_broadcast (&buffer_cond);
+
   while (current_thread->pthread_id != next_thread)
     pthread_cond_wait (&buffer_cond, &global_lock);