unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: Akira Kyle <ak@akirakyle.com>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	Emacs developers <emacs-devel@gnu.org>
Subject: Re: "Asynchronous Requests from Emacs Dynamic Modules"
Date: Sun, 1 Nov 2020 21:32:48 +0100	[thread overview]
Message-ID: <CAArVCkRdVJu0avQCKmtZ5tKQJ-56Xn1yP+cYaxKRA7w4+EJjVw@mail.gmail.com> (raw)
In-Reply-To: <867dr4omov.fsf@akirakyle.com>

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	other threads:[~2020-11-01 20:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-30 21:35 "Asynchronous Requests from Emacs Dynamic Modules" Akira Kyle
2020-10-30 22:39 ` Stefan Monnier
2020-10-31  3:18 ` Zhu Zihao
2020-10-31  7:45   ` Eli Zaretskii
2020-10-31  8:02     ` yyoncho
2020-10-31  9:13       ` Eli Zaretskii
2020-10-31  9:45         ` yyoncho
2020-10-31 10:43           ` Eli Zaretskii
2020-10-31 19:25             ` Akira Kyle
2020-10-31 20:18               ` Eli Zaretskii
2020-11-01  0:14                 ` Akira Kyle
2020-11-01 18:28                   ` Eli Zaretskii
2020-11-01 20:15                     ` Akira Kyle
2020-11-01 20:51                       ` async-await (was: Re: "Asynchronous Requests from Emacs Dynamic Modules") Philipp Stephani
2020-11-02 15:22                       ` "Asynchronous Requests from Emacs Dynamic Modules" Eli Zaretskii
2020-10-31  7:36 ` Philipp Stephani
2020-10-31 12:49   ` Stefan Monnier
2020-11-01 20:18     ` Akira Kyle
2020-11-01 20:32       ` Philipp Stephani [this message]
2020-11-20 15:54     ` Zhu Zihao
2020-11-20 16:04       ` Robert Pluim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAArVCkRdVJu0avQCKmtZ5tKQJ-56Xn1yP+cYaxKRA7w4+EJjVw@mail.gmail.com \
    --to=p.stephani2@gmail.com \
    --cc=ak@akirakyle.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).