emacs-devel
[Top][All Lists]
Advanced

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

Re: "Asynchronous Requests from Emacs Dynamic Modules"


From: Philipp Stephani
Subject: Re: "Asynchronous Requests from Emacs Dynamic Modules"
Date: Sat, 31 Oct 2020 08:36:06 +0100

Am Fr., 30. Okt. 2020 um 22:36 Uhr schrieb Akira Kyle <ak@akirakyle.com>:
>
> I'm trying to use Emacs' Dynamic Modules in an asynchronous
> setting where C module functions run in a separate thread from
> Emacs' main thread which is responsible for calling into the
> module functions. The natural problem then is how to notify Emacs
> when one wants to retrieve the result of the asynchronous
> operation from some lisp. Since the module docs explicitly say
> that module functions "may only interact with Emacs from Lisp
> interpreter threads (including the main thread) created by Emacs",
> it is not possible then for a separate module thread to interact
> with Emacs in an unprompted way through the module interface [1].
>
> This blog post [2] has a solution to this problem by sending
> SIGUSR1 to Emacs, but that feels a bit hackish and forces one to
> do more work to manage all the different possible module threads
> and events that one may want to signal to Emacs. I suppose one
> could also conceivably also use Emacs' dbus support but that still
> feels clunky. Maybe its possible it's possible to use Emacs lisp's
> threads [2] to solve this but it's not clear to me how to go about
> doing so and I haven't found anyone that has done so.
>
> Does anyone know of the best way to handle this? Perhaps the
> module interface should be expanded to handle this situation?

With Emacs 28, you can get a file descriptor to a pipe process and
send arbitrary data there (from arbitrary threads). You'd still need
some small protocol (e.g. JSON) to encode/decode requests, but with
that you can send arbitrary requests back asynchronously.



reply via email to

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