From mboxrd@z Thu Jan 1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Philipp Stephani
Newsgroups: gmane.emacs.devel
Subject: Re: "Asynchronous Requests from Emacs Dynamic Modules"
Date: Sat, 31 Oct 2020 08:36:06 +0100
Message-ID:
References: <86imarfldb.fsf@akirakyle.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
logging-data="11479"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: Emacs developers
To: Akira Kyle
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Oct 31 08:36:53 2020
Return-path:
Envelope-to: ged-emacs-devel@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.92)
(envelope-from )
id 1kYlRV-0002vl-37
for ged-emacs-devel@m.gmane-mx.org; Sat, 31 Oct 2020 08:36:53 +0100
Original-Received: from localhost ([::1]:44550 helo=lists1p.gnu.org)
by lists.gnu.org with esmtp (Exim 4.90_1)
(envelope-from )
id 1kYlRU-0001ji-5r
for ged-emacs-devel@m.gmane-mx.org; Sat, 31 Oct 2020 03:36:52 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56314)
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from )
id 1kYlQy-0001Iy-Ne
for emacs-devel@gnu.org; Sat, 31 Oct 2020 03:36:20 -0400
Original-Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]:37752)
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.90_1) (envelope-from )
id 1kYlQx-0003wo-1F
for emacs-devel@gnu.org; Sat, 31 Oct 2020 03:36:20 -0400
Original-Received: by mail-ot1-x32f.google.com with SMTP id m22so7737449ots.4
for ; Sat, 31 Oct 2020 00:36:17 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=siWL7ty9Bz+TPT1DwP3zxWjezBwDXUSW+zAOO8sEJHo=;
b=KGLYMbjdC02VbKayFzDEQL0TSkvazy+C7X3v+aiZJqg2ry2zdFrREtFW6q3WwUy+tt
bJNh4bWCK+yWSD9I+Dtj/YL9Ir42UxdypXEcGoCsw4JJHYsoHIsd5IiCrHHZSeN4mLEs
b1ZaGEwLggBRek5HDqXXZYh9vnB6wNo2QwmsJQSgHLWrmyHMRVIWiOi7Peh3+/MO6jnq
bgJPivo5cH5AA/ZlgKkcz6+m+awj4eVUijUg+JKX1+DPzURT9FRtUpDKMEYRu1VgyiHW
eQkkfVij3Y4tgJXsowFQZ6h+6cDMRB31jbjXlC5GzmfgA/pjVFTJ/qkxetF+kW3xqknA
kdbw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=siWL7ty9Bz+TPT1DwP3zxWjezBwDXUSW+zAOO8sEJHo=;
b=G6kRhEmlsQQK5uN4BV/+fk/pxrE3axafiMjnEJvLUMhfIP3vZh6yohNcfrchVBLnjk
N0dgSzVi335xhAaDMdxgVHOodwwIiexq1odop7TfLWrTispHrKPsepitV/xZwupixs1l
EVAhEO1HvSO4iAk28PV8DTEr45GA/fng10r756hl9uk+yIxACH43Tm/ZuVZEfy4+75dA
P8v5tMTdOqI++wnkRdTey3/RQY46RL+T8RaZeFenNLOIV05mh+KpkKkmOLEZIB2+Nb6M
ggaOVIX3dFmPBJZ5i1YfYkFZIUUknDr0zBCuWMim+NqInXfDs5cvvaa8atqKOLirTbTf
YlmQ==
X-Gm-Message-State: AOAM5339UEBh0Wzy/B32ZN6/qiYEfqHSSGwOX5BI2V5pFwQoJQMreYjA
fu9KMovcHh6BdqXe3Hz+Z2z111mZVwbFcILolnU=
X-Google-Smtp-Source: ABdhPJzJvihkxRxlweJRWzpa4wrz9N+jH96EXtH7jQXSLwf2HKB2M/sRA1IywKAwXAwkQuhLKzkqk2xxggAJGEdH4+0=
X-Received: by 2002:a9d:12f3:: with SMTP id g106mr4295650otg.149.1604129776844;
Sat, 31 Oct 2020 00:36:16 -0700 (PDT)
In-Reply-To: <86imarfldb.fsf@akirakyle.com>
Received-SPF: pass client-ip=2607:f8b0:4864:20::32f;
envelope-from=p.stephani2@gmail.com; helo=mail-ot1-x32f.google.com
X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache.
That's all we know.
X-Spam_score_int: -17
X-Spam_score: -1.8
X-Spam_bar: -
X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: "Emacs development discussions."
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org
Original-Sender: "Emacs-devel"
Xref: news.gmane.io gmane.emacs.devel:258573
Archived-At:
Am Fr., 30. Okt. 2020 um 22:36 Uhr schrieb Akira Kyle :
>
> 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.