From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: ndame Newsgroups: gmane.emacs.help Subject: Re: Is automatic yield support feasible for threads? Date: Wed, 10 Nov 2021 07:46:48 +0000 Message-ID: References: <46501A5F-9C72-4048-8EEA-CE219D54CEC2@gmail.com> Reply-To: ndame Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2517"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "help-gnu-emacs@gnu.org" To: Philipp Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 10 08:47:40 2021 Return-path: Envelope-to: geh-help-gnu-emacs@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 1mkiKa-0000OA-N0 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 10 Nov 2021 08:47:40 +0100 Original-Received: from localhost ([::1]:48410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkiKZ-0001gz-Dt for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 10 Nov 2021 02:47:39 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:47174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkiK2-0001gk-EF for help-gnu-emacs@gnu.org; Wed, 10 Nov 2021 02:47:06 -0500 Original-Received: from mail-40135.protonmail.ch ([185.70.40.135]:14360) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkiJw-0003PY-Ur for help-gnu-emacs@gnu.org; Wed, 10 Nov 2021 02:47:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1636530411; bh=SSYwZqGlf+WveXlWZyOZ6++QgVmGIEt3Rk7Gt0TDcwQ=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=iTQ0hAl18H5BAezMop+zR7X5fdr2fqXVnFBD/fvZ61V1RapaXIEiKh/csn9bZh1YO eQMImNA01Aqe5PvAbWXgCQq3GlzsiygGg2P5HMbjjMh/IbcSLmg9taci3RP+0JAXx5 bSk4JE3ADnWVW19G6ZBkHpWC7PEKi0BYWzFbNEgY= In-Reply-To: <46501A5F-9C72-4048-8EEA-CE219D54CEC2@gmail.com> Received-SPF: pass client-ip=185.70.40.135; envelope-from=laszlomail@protonmail.com; helo=mail-40135.protonmail.ch X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:134470 Archived-At: On Tuesday, November 9th, 2021 at 3:53 PM, Philipp = wrote: > > I don't think it's feasible. Emacs Lisp code typically relies heavily on = mutating global state (think buffer contents, the buffer list, `point', dyn= amic variables, ...), and normally doesn't put such state mutations into pr= operly synchronized critical sections. Yielding from such unprotected criti= cal sections would result in very subtle bugs (`point' randomly moving arou= nd, corruption of internal data structures, buffers vanishing surprisingly,= ...). I don't think threads should be used for UI manipulation, that should be le= ft for the main thread. Threads are more useful for longer running calculat= ions, computations and those should have no problem if they work on local d= ata. But you are right if someone uses a thread for UI changes then there can be= problems. My idea is about an _optional_ automatic yielding for threads, s= o it still could be useful for those threads which are self contained. Thos= e could choose to start with periodic automatic yielding, so their code do = not have to be sprinkled with manual yield calls, impacting code readabilit= y.