]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove the buffer-locking mechanism.
authorGiuseppe Scrivano <gscrivano@gnu.org>
Mon, 9 Nov 2009 19:35:43 +0000 (20:35 +0100)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Mon, 9 Nov 2009 19:35:43 +0000 (20:35 +0100)
src/buffer.c
src/buffer.h
src/thread.c
src/thread.h

index 01531ca8c740d71b55c6e2974ec0b29f6fd69cea..648ae1d004f5c7f834b5b2869184435f31cb4308 100644 (file)
@@ -415,9 +415,7 @@ b->width_table_ = Qnil;
 
   b->mark_ = Fmake_marker ();
   BUF_MARKERS (b) = NULL;
-  b->name_ = name;
-  b->owner = Qnil;
-  b->prev_owner = Qnil;
+  b->name = name;
 
   /* Put this in the alist of all live buffers.  */
   XSETBUFFER (buffer, b);
@@ -599,7 +597,6 @@ CLONE nil means the indirect buffer's state is reset to default values.  */)
 
   BUF_MARK (b) = Fmake_marker ();
   BUF_NAME (b) = name;
-  b->owner = Qnil;
 
   /* The multibyte status belongs to the base buffer.  */
   BUF_ENABLE_MULTIBYTE_CHARACTERS (b) = BUF_ENABLE_MULTIBYTE_CHARACTERS (b->base_buffer);
@@ -1444,10 +1441,6 @@ with SIGHUP.  */)
   if (NILP (BUF_NAME (b)))
     return Qnil;
 
-  tem = get_current_thread ();
-  if (!EQ (b->owner, Qnil) && !EQ (b->owner, tem))
-    error ("Buffer locked by another thread");
-
   /* Query if the buffer is still modified.  */
   if (INTERACTIVE && !NILP (BUF_FILENAME (b))
       && BUF_MODIFF (b) > BUF_SAVE_MODIFF (b))
@@ -1877,7 +1870,6 @@ set_buffer_internal_1 (b)
     return;
 
   old_buf = current_buffer;
-  flush_stack_call_func (thread_acquire_buffer, b);
   current_buffer = b;
   last_known_column_point = -1;   /* invalidate indentation cache */
 
@@ -5208,16 +5200,14 @@ init_buffer_once ()
   buffer_defaults.overlays_after = NULL;
   buffer_defaults.overlay_center = BEG;
 
-  XSETFASTINT (BUF_TAB_WIDTH (&buffer_defaults), 8);
-  BUF_TRUNCATE_LINES (&buffer_defaults) = Qnil;
-  BUF_WORD_WRAP (&buffer_defaults) = Qnil;
-  BUF_CTL_ARROW (&buffer_defaults) = Qt;
-  BUF_DIRECTION_REVERSED (&buffer_defaults) = Qnil;
-  BUF_CURSOR_TYPE (&buffer_defaults) = Qt;
-  BUF_EXTRA_LINE_SPACING (&buffer_defaults) = Qnil;
-  BUF_CURSOR_IN_NON_SELECTED_WINDOWS (&buffer_defaults) = Qt;
-  buffer_defaults.owner = Qnil;
-  buffer_defaults.prev_owner = Qnil;
+  XSETFASTINT (buffer_defaults.tab_width, 8);
+  buffer_defaults.truncate_lines = Qnil;
+  buffer_defaults.word_wrap = Qnil;
+  buffer_defaults.ctl_arrow = Qt;
+  buffer_defaults.direction_reversed = Qnil;
+  buffer_defaults.cursor_type = Qt;
+  buffer_defaults.extra_line_spacing = Qnil;
+  buffer_defaults.cursor_in_non_selected_windows = Qt;
 
 #ifdef DOS_NT
   buffer_defaults.buffer_file_type = Qnil; /* TEXT */
index fb37497d9451f9072de33c6fc3ea400aab448cdd..28e344a407128b3531f2078a77fa9e5025284c99 100644 (file)
@@ -799,13 +799,7 @@ struct buffer
   /* *Cursor type to display in non-selected windows.
      t means to use hollow box cursor.
      See `cursor-type' for other values.  */
-  Lisp_Object cursor_in_non_selected_windows_;
-
-  /* If non-nil, the thread holding a lock on this buffer.  */
-  Lisp_Object owner;
-
-  /* If non-nil, the previous thread holding a lock on this buffer.  */
-  Lisp_Object prev_owner;
+  Lisp_Object cursor_in_non_selected_windows;
 };
 
 #define BUF_CURSOR_IN_NON_SELECTED_WINDOWS(BUF) *find_variable_location (&((BUF)->cursor_in_non_selected_windows_))
index 6663c369d1fe641bccd23f585e9223188afd7490..07840c43d605c4230263ce1e7549bfa2890ca8eb 100644 (file)
@@ -37,43 +37,7 @@ static pthread_t next_thread;
 static void
 thread_schedule ()
 {
-  struct thread_state *it, *begin = NEXT_THREAD (current_thread);
-
-#define CHECK_THREAD(T,B)                                       \
-  if ((!other_threads_p ()                                     \
-       || ((struct thread_state *)T)->nolock                   \
-       || EQ (((struct thread_state *)T)->desired_buffer,      \
-             ((struct thread_state *)T)->m_current_buffer)     \
-       || EQ (B->owner, Qnil)                                  \
-      /* We set the owner to Qt to mean it is being killed.  */ \
-       || EQ (B->owner, Qt))                                   \
-      && !((struct thread_state *)T)->blocked)                 \
-    {                                                           \
-      next_thread = ((struct thread_state *)T)->pthread_id;     \
-      return;                                                   \
-    }                                                           \
-
-  /* Try to wake up the thread holding the 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.   */
-  it = begin;
-  while (1)
-    {
-      struct buffer *new_buffer = it->desired_buffer;
-      if (new_buffer)
-       CHECK_THREAD (it, new_buffer);
-
-      it = NEXT_THREAD (it);
-      if (it == current_thread)
-        break;
-    }
+  next_thread = NEXT_THREAD (current_thread)->pthread_id;
 }
 
 /* Schedule a new thread and block the caller until it is not scheduled
@@ -180,29 +144,6 @@ unmark_threads (void)
       unmark_byte_stack (iter->m_byte_stack_list);
 }
 
-void
-thread_acquire_buffer (char *end, void *nb)
-{
-  struct buffer *new_buffer = nb;
-  current_thread->desired_buffer = new_buffer;
-  if (current_buffer)
-    {
-      current_buffer->owner = current_buffer->prev_owner;
-      current_buffer->prev_owner = Qnil;
-    }
-
-  reschedule (end, 1);
-
-  /* FIXME: if buffer is killed */
-  new_buffer->prev_owner = new_buffer->owner;
-  if (current_thread->nolock)
-    new_buffer->owner = Qnil;
-  else
-    new_buffer->owner = get_current_thread ();
-
-  current_buffer = new_buffer;
-}
-
 int
 thread_inhibit_yield_p  ()
 {
@@ -303,9 +244,6 @@ run_thread (void *state)
     ;
   *iter = (*iter)->next_thread;
 
-  if (!EQ (self->m_current_buffer->owner, Qt))
-    self->m_current_buffer->owner = self->m_current_buffer->prev_owner;
-
   thread_schedule ();
   pthread_cond_broadcast (&buffer_cond);
 
@@ -316,13 +254,11 @@ run_thread (void *state)
   return NULL;
 }
 
-DEFUN ("run-in-thread", Frun_in_thread, Srun_in_thread, 1, 2, 0,
+DEFUN ("run-in-thread", Frun_in_thread, Srun_in_thread, 1, 1, 0,
        doc: /* Start a new thread and run FUNCTION in it.
-When the function exits, the thread dies.  When NOLOCK is no-nil the thread
-does not try to get a lock on the current buffer.  */)
-     (function, nolock)
+When the function exits, the thread dies.  */)
+     (function)
      Lisp_Object function;
-     Lisp_Object nolock;
 {
   char stack_pos;
   pthread_t thr;
@@ -341,7 +277,6 @@ does not try to get a lock on the current buffer.  */)
 
   new_thread->func = function;
   new_thread->blocked = 0;
-  new_thread->nolock = !EQ (nolock, Qnil);
   new_thread->initial_specpdl = Qnil;
   new_thread->m_last_thing_searched = Qnil; /* copy from parent? */
   new_thread->m_saved_last_thing_searched = Qnil;
@@ -509,7 +444,6 @@ init_threads (void)
   pthread_mutex_lock (&global_lock);
 
   primary_thread.pthread_id = pthread_self ();
-  primary_thread.nolock = 0;
   primary_thread.blocked = 0;
   primary_thread.m_last_thing_searched = Qnil;
   next_thread = primary_thread.pthread_id;
index f9495893d5f9917b0b576c8415b92d7072f5876d..df98276fc81aa07a1611c450773aa0873170db2f 100644 (file)
@@ -111,9 +111,6 @@ struct thread_state
 
   pthread_t pthread_id;
 
-  /* If nonzero the thread access a buffer without lock it.  */
-  int nolock;
-
   /* Used internally by the scheduler, the buffer that the thread wants a lock
      for.  */
   struct buffer *desired_buffer;
@@ -146,6 +143,4 @@ EXFUN (Finhibit_yield, 1);
 
 extern int thread_inhibit_yield_p  P_ ((void));
 
-extern void thread_acquire_buffer (char *, void *);
-
 extern Lisp_Object thread_notify_kill_buffer (register struct buffer *b);