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);
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);
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))
return;
old_buf = current_buffer;
- flush_stack_call_func (thread_acquire_buffer, b);
current_buffer = b;
last_known_column_point = -1; /* invalidate indentation cache */
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 */
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
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 ()
{
;
*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);
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;
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;
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;