/* If our desired buffer is locked, wait for it. */
while (other_threads_p ()
+ && !current_thread->nolock
&& !EQ (new_buffer->owner, Qnil)
/* We set the owner to Qt to mean it is being killed. */
&& !EQ (new_buffer->owner, Qt))
flush_stack_call_func (acquire_buffer, b);
/* FIXME: if buffer is killed */
b->prev_owner = b->owner;
- b->owner = get_current_thread ();
+ if (current_thread->nolock)
+ b->owner = Qnil;
+ else
+ b->owner = get_current_thread ();
current_buffer = b;
last_known_column_point = -1; /* invalidate indentation cache */
return NULL;
}
-DEFUN ("run-in-thread", Frun_in_thread, Srun_in_thread, 1, 1, 0,
+DEFUN ("run-in-thread", Frun_in_thread, Srun_in_thread, 1, 2, 0,
doc: /* Start a new thread and run FUNCTION in it.
-When the function exits, the thread dies. */)
- (function)
+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)
Lisp_Object function;
+ Lisp_Object nolock;
{
char stack_pos;
pthread_t thr;
m_gcprolist));
new_thread->func = function;
+ new_thread->nolock = !EQ (nolock, Qnil);
new_thread->initial_specpdl = Qnil;
new_thread->m_current_buffer = current_thread->m_current_buffer;
new_thread->stack_bottom = &stack_pos;
}
DEFUN ("inhibit-yield", Finhibit_yield, Sinhibit_yield, 1, 1, 0,
- doc: /* Inhibit the yield function. */)
+ doc: /* Inhibit the yield function. */)
(val)
Lisp_Object val;
{
pthread_mutex_init (&global_lock, NULL);
pthread_mutex_lock (&global_lock);
primary_thread.pthread_id = pthread_self ();
+ primary_thread.nolock = 0;
}
void