From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [RFC] Adding threads to Eshell Date: Fri, 16 Dec 2022 21:51:24 +0200 Message-ID: <83mt7ni0ub.fsf@gnu.org> References: <7f4e3357-2c6a-a0d2-cab5-fb641b52877a@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12206"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Jim Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 16 20:52:02 2022 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 1p6GkT-0002sA-2O for ged-emacs-devel@m.gmane-mx.org; Fri, 16 Dec 2022 20:52:01 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6Gk8-0002tr-7k; Fri, 16 Dec 2022 14:51:40 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6Gjq-0002tJ-DO for emacs-devel@gnu.org; Fri, 16 Dec 2022 14:51:28 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6Gjp-000892-VA; Fri, 16 Dec 2022 14:51:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=zi2OEYbKJ0wCQb6cceYc+kqR52PgDrAp4fIusHw6Tn8=; b=M2i69p7fedb4 Zy/PRSinVS/iIqLSCchgEHHbOA9Nnb1q09e+3nGMscEaYnpfNJTKVO8TizCsoL3aOev7g+CNSgm2n /T4pRsaOBjBiRekMoShlnQWZX/ms6thqT8YgshiuvmIDkdHCkWQ5fvGIotPA8wxR19dXdDudT6pxO hN03FxWZK5vEzQiyof65/zBHSmI+siv0vvRNjtjfWNU0qry7VacNsU0o+Jl5AsDiHriD8Q32I4aF/ b+eiiXiB1OE/u2ZHri9SDN6k6L7buJJ2nSdWryUGR+xp7N0CF0iwRFNfXiMcdDXJ/NcjREAXsS+Jr AMLHL7p2rj6d5vIvPwlECA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6Gjp-00048c-9w; Fri, 16 Dec 2022 14:51:21 -0500 In-Reply-To: <7f4e3357-2c6a-a0d2-cab5-fb641b52877a@gmail.com> (message from Jim Porter on Thu, 15 Dec 2022 18:37:09 -0800) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:301522 Archived-At: > Date: Thu, 15 Dec 2022 18:37:09 -0800 > From: Jim Porter > > However, before I go too far, I wanted to check with other, more > knowledgeable people: are Emacs threads available on all platforms? Yes. The only known exception is MSDOS. > It looks like it requires the pthreads library pthreads are required only on Posix platforms; on Windows we use Windows-specific APIs instead. See systhread.c. > (though my understanding was > that Emacs threads aren't "real" threads, since there's no good way to > avoid data races with globals). No, they are real threads. You can see them with any OS-level tool that can examine threads. We just let only a single one of these threads to run at any given time (well, with the exception of very short time windows). > A second issue I noticed is that Emacs threads have their own, > completely separate set of lexical bindings. Not lexical bindings: local bindings. That is, if you let-bind a variable, that binding is only seen in the thread that performed the binding. > Is it possible to tell a thread that I want to inherit the bindings > from wherever I called 'make-thread'? Global bindings are always shared. > I might be able to avoid this issue, but it would be nice to be able > to let-bind some defvars and then pass those bindings to an Eshell > command to do its thing. If that is what you want, you will have to pass those bindings as arguments to the thread function.