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: Sun, 1 Nov 2020 21:32:48 +0100

Am So., 1. Nov. 2020 um 21:18 Uhr schrieb Akira Kyle <ak@akirakyle.com>:
>
>
> On Sat, Oct 31, 2020 at 06:49 AM, Stefan Monnier
> <monnier@iro.umontreal.ca> wrote:
>
> >> With Emacs 28, you can get a file descriptor to a pipe process
> >> and
> >> send arbitrary data there (from arbitrary threads).
> >
> > Cool, so that takes care of it.
> >
> >> You'd still need some small protocol (e.g. JSON) to
> >> encode/decode
> >> requests, but with that you can send arbitrary requests
> >> back asynchronously.
> >
> > I don't think you need a complex protocol: just stash somewhere
> > (inside
> > the module data structures) the data you need for the async
> > request,
> > then send a dummy byte to the pipe.  On the Lisp side, just
> > install
> > a process-filter which calls back the module to "run any pending
> > async
> > requests".
>
> Thanks Philipp for pointing this out! I'm glad this was already
> thought of and added so the SIGUSR1 hack isn't necessary going
> forward. For future reference, the module function is
> `open_channel`.

I actually implemented open_channel after reading that very blogpost
and thinking "there has to be a better way" :-)
Note that even without that there are a few other options, e.g.
starting a Unix domain socket server in Emacs and then connecting to
it from the module. These are essentially equivalent in that they
queue some form of event (process input) that can be processed
asynchronously on the Emacs side.



reply via email to

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