From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Elias_M=C3=A5rtenson?= Newsgroups: gmane.emacs.devel Subject: Re: Threading IO-bound functions Date: Mon, 19 Dec 2016 15:06:32 +0800 Message-ID: References: <8360mj99oe.fsf@gnu.org> <83fulk610j.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11443a8a4c1b670543fd8f24 X-Trace: blaine.gmane.org 1482131205 15333 195.159.176.226 (19 Dec 2016 07:06:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 19 Dec 2016 07:06:45 +0000 (UTC) Cc: emacs-devel To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 19 08:06:41 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cIs1w-0003Rg-I3 for ged-emacs-devel@m.gmane.org; Mon, 19 Dec 2016 08:06:40 +0100 Original-Received: from localhost ([::1]:43802 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cIs20-0007Ei-PJ for ged-emacs-devel@m.gmane.org; Mon, 19 Dec 2016 02:06:44 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cIs1t-0007Ec-QA for emacs-devel@gnu.org; Mon, 19 Dec 2016 02:06:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cIs1s-00048L-Fe for emacs-devel@gnu.org; Mon, 19 Dec 2016 02:06:37 -0500 Original-Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:37142) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cIs1q-00046u-Kt; Mon, 19 Dec 2016 02:06:34 -0500 Original-Received: by mail-wm0-x22d.google.com with SMTP id t79so92224404wmt.0; Sun, 18 Dec 2016 23:06:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Hf6tp0kJ3mlFoQUXikYOHU8IntqR9h/eU4E4kG4Chos=; b=k5bF5b+UKei0nSMe3KSMQFYAzazOZl9p2S4oe6pzuUK30kEsr14hL16OSL+rxoVtO7 VjYQJSk56F8oDDhTzbzIQIVz3hdkpYZ8vC9LnZ453Nvdve/ugZ6yrljJ/qXHCG1zImdf EMm1+T1OkHQna/CmbA+mFMipHPpGIaD/8p7wsjUQONpAjCCgTp5eP9Java92OTd/8s55 DtkYD4oyULf70bt2acL9YKzieJZXI9ceDbiH818geCN7DlQ8DnwoJAdKjJcsFmCOiLUn +4PCpx6gPt3x5RMJY8pJI2uVhk8Nz74FLqjatXqrCEmFQdP5B5c5hOfkZSbthaGvYU2p Bt7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Hf6tp0kJ3mlFoQUXikYOHU8IntqR9h/eU4E4kG4Chos=; b=mLRxCis4Uc5zMp7BTLArQJgEI30tyWd95OS5UOr25IHJfyyFMPDMsMoLfUApDEROEq kPd2dwdjnbuGw+sIqs1RTSjOQfO22jHI47jRPiKgmgxf1dDIfknRhtAj27Ir30TtGuxW SHAzEk1ujcSUgLBB36ZXwReknd0W5n4DZjzqtPIUNNmsDomtIDTZJtOB31JEN2jvA+Cm +xhg8jFLspO4ckR1xZZ7LtGA34pVeJ5uFJ6UW+4QFDjukt4RGwLdL9I2eLNV3BXgOqBq R/9qXcFnFmBW+6Uw+r+vNE/oJgHzb2LmAwxqe8NQUPly1Ohw/vH9W3cGszERSvLk+Z9f DWuA== X-Gm-Message-State: AIkVDXLC7gGH2y3YGrQfA3XkxvMHao205bzGO8vh6nhcjQtp3TeGK/GKRRrQ6P9AoGQZ0r8qCFf2ByzIXEgrbw== X-Received: by 10.28.136.198 with SMTP id k189mr11634803wmd.24.1482131193468; Sun, 18 Dec 2016 23:06:33 -0800 (PST) Original-Received: by 10.80.135.165 with HTTP; Sun, 18 Dec 2016 23:06:32 -0800 (PST) In-Reply-To: <83fulk610j.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:210618 Archived-At: --001a11443a8a4c1b670543fd8f24 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 19 December 2016 at 11:39, Eli Zaretskii wrote: > > From: Elias M=C3=A5rtenson > > Date: Mon, 19 Dec 2016 11:03:32 +0800 > > Cc: emacs-devel > > > > 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 =E2=80=98read-string=E2=80=99 or= some variant > like =E2=80=98completing-read=E2=80=99, 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 =E2=80=98or-or-n-p=E2=80= =99 or =E2=80=98read-string=E2=80=99 or other similar things. This should be imple= mented 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 --001a11443a8a4c1b670543fd8f24 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On 1= 9 December 2016 at 11:39, Eli Zaretskii <eliz@gnu.org> wrote:
=
> From: Elias M=C3=A5rtenson <lokedhs@gmail.com>
> Date: Mon, 19 Dec 2016 11:03:32 +0800
> Cc: emacs-devel <emacs-devel= @gnu.org>
>
>=C2=A0 I think we need first to solve the above problem in some way. Or=
>=C2=A0 change Gnus to not ask any questions from a background thread. >
> I think most questions are asked using =E2=80=98read-string=E2=80=99 o= r some variant like =E2=80=98completing-read=E2=80=99, right? At the very > least, I think that concurrent Emacs needs to make sure that the behav= iour of these functions are well-defined
> in the context of threading.

I asked for thoughts and ideas about this in bug#25214.=C2=A0 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 mention= ed in a bug report it doesn't surprise me that not so many people see i= t.

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

=
Naturally, a threaded function may want to invoke =E2=80=98or-or-n-p= =E2=80=99 or =E2=80=98read-string=E2=80=99 or other similar things. This sh= ould 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 ma= in thread would see the request on the queue and invoke the appropriate key= board-interaction-function at the appropriate time.

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

=
Regards,
Elias
--001a11443a8a4c1b670543fd8f24--