emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threading IO-bound functions


From: Elias Mårtenson
Subject: Re: Threading IO-bound functions
Date: Mon, 19 Dec 2016 15:06:32 +0800

On 19 December 2016 at 11:39, Eli Zaretskii <address@hidden> wrote:
> From: Elias Mårtenson <address@hidden>
> Date: Mon, 19 Dec 2016 11:03:32 +0800
> Cc: emacs-devel <address@hidden>
>
>  I think we need first to solve the above problem in some way. Or
>  change Gnus to not ask any questions from a background thread.
>
> I think most questions are asked using ‘read-string’ or some variant like ‘completing-read’, right? At the very
> least, I think that concurrent Emacs needs to make sure that the behaviour of these functions are well-defined
> in the context of threading.

I asked for thoughts and ideas about this in bug#25214.  So far no
replies, which I find unfortunate and, frankly, surprising.

I thought that I had been reading all the concurrency-related threads, but I don't recall seeing this. If it was only mentioned in a bug report it doesn't surprise me that not so many people see it.

Now, my thoughts on this is that keyboard entry is an inherently single-threaded operation from the user's point of view and that the Emacs platform should enforce this. Thus, keyboard input should only be allowed from the main thread.

Naturally, a threaded function may want to invoke ‘or-or-n-p’ or ‘read-string’ or other similar things. This should be implemented using a queue where the thread places an input request on the queue and waits for the main thread to reply with the result. The main thread would see the request on the queue and invoke the appropriate keyboard-interaction-function at the appropriate time.

At least that's how I would design it. Thoughts?

Regards,
Elias

reply via email to

[Prev in Thread] Current Thread [Next in Thread]