;; for more input to decide how to interpret the
;; current input.
(throw 'read-key keys)))))))
- (with-no-threads
+ (with-critical-section minibuffer-mutex
(unwind-protect
(progn
(use-global-map read-key-empty-map)
or the octal character code.
RET terminates the character code and is discarded;
any other non-digit terminates the character code and is then used as input."))
- (with-no-threads
+ (with-critical-section minibuffer-mutex
(setq char (read-event (and prompt (format "%s-" prompt)) t)))
(if inhibit-quit (setq quit-flag nil)))
;; Translate TAB key into control-I ASCII character, and so on.
Once the caller uses the password, it can erase the password
by doing (clear-string STRING)."
(with-local-quit
- (with-no-threads
+ (with-critical-section minibuffer-mutex
(if confirm
(let (success)
(while (not success)
"Read a numeric value in the minibuffer, prompting with PROMPT.
DEFAULT specifies a default value to return if the user just types RET.
The value of DEFAULT is inserted into PROMPT."
- (with-no-threads
+ (with-critical-section minibuffer-mutex
(let ((n nil))
(when default
(setq prompt
\f
;;;; Lisp macros to do various things temporarily.
-(defmacro with-no-threads (&rest body)
- "Disable temporarily other threads to be executed."
+(defmacro with-critical-section (mutex &rest body)
+ "Execute code in a critical section."
(declare (indent 1) (debug t))
`(unwind-protect
- (progn (inhibit-yield t)
+ (progn (mutex-lock mutex)
,@body)
- (inhibit-yield nil)))
+ (mutex-unlock mutex)))
(defmacro with-current-buffer (buffer-or-name &rest body)
"Execute the forms in BODY with BUFFER-OR-NAME temporarily current.
Lisp_Object ret;
int count = SPECPDL_INDEX ();
- Finhibit_yield (Qt);
- record_unwind_protect (Finhibit_yield, Qnil);
+ Fmutex_lock (minibuffer_mutex);
+ record_unwind_protect (Fmutex_unlock, minibuffer_mutex);
ret = Fyes_or_no1 (prompt);
- Finhibit_yield (Qnil);
unbind_to (count, Qnil);
return ret;
}
if (display_hourglass_p)
cancel_hourglass ();
#endif
- Finhibit_yield (Qt);
- record_unwind_protect (Finhibit_yield, Qnil);
+ Fmutex_lock (minibuffer_mutex);
+ record_unwind_protect (Fmutex_unlock, minibuffer_mutex);
i = read_key_sequence (keybuf, (sizeof keybuf/sizeof (keybuf[0])),
prompt, ! NILP (dont_downcase_last),
extern Lisp_Object memory_signal_data;
+extern Lisp_Object minibuffer_mutex;
+
/* Check quit-flag and quit if it is non-nil.
Typing C-g does not directly cause a quit; it only sets Vquit_flag.
So the program needs to do QUIT at times when it is safe to quit.
EXFUN (Fsub1, 1);
EXFUN (Fmake_variable_buffer_local, 1);
+EXFUN (Fmake_mutex, 0);
+EXFUN (Fmutex_lock, 1);
+EXFUN (Fmutex_unlock, 1);
+
+
extern struct Lisp_Symbol *indirect_variable (struct Lisp_Symbol *);
extern Lisp_Object *find_variable_location (Lisp_Object *);
extern Lisp_Object ensure_thread_local (Lisp_Object *);
minibuf_save_list))))));
- Finhibit_yield (Qt);
- record_unwind_protect (Finhibit_yield, Qnil);
+ Fmutex_lock (minibuffer_mutex);
+ record_unwind_protect (Fmutex_unlock, minibuffer_mutex);
record_unwind_protect (read_minibuf_unwind, Qnil);
minibuf_level++;
__thread struct thread_state *current_thread = &primary_thread;
-static int inhibit_yield_counter = 0;
-
pthread_mutex_t global_lock;
/* Used internally by the scheduler, it is the next that will be executed. */
static pthread_t next_thread;
+Lisp_Object minibuffer_mutex;
+
/* Choose the next thread to be executed. */
static void
thread_schedule ()
reschedule (char *end, int wait)
{
current_thread->stack_top = end;
- if (!thread_inhibit_yield_p ())
- thread_schedule ();
+ thread_schedule ();
if (next_thread != current_thread->pthread_id)
pthread_cond_broadcast (&thread_cond);
unmark_byte_stack (iter->m_byte_stack_list);
}
-int
-thread_inhibit_yield_p ()
-{
- return inhibit_yield_counter || interrupt_input_blocked || abort_on_gc;
-}
-
static void
thread_yield_callback (char *end, void *ignore)
{
- if (!thread_inhibit_yield_p ())
- reschedule (end, 1);
+ reschedule (end, 1);
}
void
return 0;
}
-DEFUN ("inhibit-yield", Finhibit_yield, Sinhibit_yield, 1, 1, 0,
- doc: /* Inhibit the yield function. */)
- (val)
- Lisp_Object val;
-{
- if (!EQ (val, Qnil))
- inhibit_yield_counter++;
- else if (inhibit_yield_counter > 0)
- inhibit_yield_counter--;
-
- return Qnil;
-}
-
DEFUN ("make-mutex", Fmake_mutex, Smake_mutex, 0, 0, 0,
doc: /* Make a mutex. */)
()
primary_thread.func = Qnil;
primary_thread.initial_specpdl = Qnil;
XSETPVECTYPE (&primary_thread, PVEC_THREAD);
+ minibuffer_mutex = Fmake_mutex ();
}
void
void
syms_of_threads (void)
{
+ DEFVAR_LISP ("minibuffer-mutex", &minibuffer_mutex,
+ doc: /* Mutex for the minibuffer. */);
+
defsubr (&Srun_in_thread);
defsubr (&Syield);
- defsubr (&Sinhibit_yield);
defsubr (&Smake_mutex);
defsubr (&Smutex_lock);
defsubr (&Smutex_unlock);
extern int user_thread_p P_ ((void));
-EXFUN (Finhibit_yield, 1);
-
-extern int thread_inhibit_yield_p P_ ((void));
-
extern Lisp_Object thread_notify_kill_buffer (register struct buffer *b);
}
}
- Finhibit_yield (Qt);
- record_unwind_protect (Finhibit_yield, Qnil);
+ Fmutex_lock (minibuffer_mutex);
+ record_unwind_protect (Fmutex_unlock, minibuffer_mutex);
retry:
if (!EQ (old_frame, selected_frame)