From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.devel Subject: Re: Should this package be included into the NS port? Date: Wed, 23 May 2018 22:21:29 +0100 Message-ID: <20180523212129.GB36578@breton.holly.idiocy.org> References: <20180515183631.GB27909@breton.holly.idiocy.org> <20180518193632.GA31241@breton.holly.idiocy.org> <20180519103329.GB31853@breton.holly.idiocy.org> <83k1rucs15.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1527110413 410 195.159.176.226 (23 May 2018 21:20:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 23 May 2018 21:20:13 +0000 (UTC) User-Agent: Mutt/1.9.3 (2018-01-21) Cc: Nick Helm , georgedp@orbitalimpact.com, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 23 23:20:08 2018 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 1fLbB1-0008Ql-BJ for ged-emacs-devel@m.gmane.org; Wed, 23 May 2018 23:20:07 +0200 Original-Received: from localhost ([::1]:35472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLbD8-0008GX-Hb for ged-emacs-devel@m.gmane.org; Wed, 23 May 2018 17:22:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLbCU-0008GH-Ih for emacs-devel@gnu.org; Wed, 23 May 2018 17:21:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLbCT-00029E-KO for emacs-devel@gnu.org; Wed, 23 May 2018 17:21:38 -0400 Original-Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:52588) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fLbCR-00028M-Ud; Wed, 23 May 2018 17:21:36 -0400 Original-Received: by mail-wm0-x233.google.com with SMTP id w194-v6so12600353wmf.2; Wed, 23 May 2018 14:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=Q1Pb3ugVZ0Rmzk/HforiXmsbKzn+IPWV+J1JTZQzAg4=; b=UpIzfxSS5f3n4iMHtQrPwNzqlz6L7WZUYCxPVQigiW1A4ruC3RQJSYNiWzbxotumg4 HDTFEvy0LSkkDbIssE84OVHFnSQqGXxf2BW++dkGcfoba0P/Ld1rco1z88hZQfsCNL0B eLmZtGOhoA0CD4+YXD0GnjfRwfCaqALkBpZI7Nde3/G3Dy7HT15pxxSshOJRNRx1vnN2 SCqLow4tlP1gzCnEO40jdiywKy/QaKJ4JMw+aA2P2OSSRsdaV7+eehsDNkeFDwx3wYwL rYm8pgLLEWyco2WPR6Ky21L7Y9VE43lTdY2moAK8clsttFscQj08sTPAM6hWGX9pTrA8 QXlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=Q1Pb3ugVZ0Rmzk/HforiXmsbKzn+IPWV+J1JTZQzAg4=; b=U+0wgvjR0mtKr7pL8woejH9B+Lyp1oPVwrPzCoYAOrGHwLBrP3Md47WcGqY/T6jFrR /en1M236WXDV+p1V1mOhnYe3Fby/8MqY9fxM7e3PiutdFkNrYK3/0kavu+fBoEAB32K8 fhPmFRvDS6QpBz0s9vg7OcwFrHjqSjJR1cYoOyb8MH7Pb2ZHTCvVKy/zNsHgc1YTltBM 6SpLIS6KIDUwvMHkrHWUdBRjbQ/J2KK+yS/Zg29z59DsmO0UYg4yfcayFxhU0h3K27tJ /5wVCH0XOeyuzzX2w86gu2k6/utoDF0pcbMdMt4T8PSlRs3GZ/12X2My4GaOzqJ3QNi2 vkXQ== X-Gm-Message-State: ALKqPwftFBcCBk6Z6vgwYlq5rTvCoWd2P8cBUjHRt+PCBuRhGlUvzNau PHaNjwYhrFwwj6USJOG9U/PeMrECApw= X-Google-Smtp-Source: AB8JxZrmW/immHlpSsP10E9OF//Z9o3bd4Zzd1CajN2saQETkVspZbQcEmsm6qa9yMehBh1hVnHVgw== X-Received: by 2002:a1c:96d3:: with SMTP id y202-v6mr4890578wmd.106.1527110494539; Wed, 23 May 2018 14:21:34 -0700 (PDT) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-3920-9846-938e-4d64.holly.idiocy.org. [2001:8b0:3f8:8129:3920:9846:938e:4d64]) by smtp.gmail.com with ESMTPSA id j13-v6sm6048193wre.38.2018.05.23.14.21.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 14:21:33 -0700 (PDT) Content-Disposition: inline In-Reply-To: <83k1rucs15.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::233 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:225635 Archived-At: On Wed, May 23, 2018 at 06:26:14PM +0300, Eli Zaretskii wrote: > > From: Nick Helm > > Date: Wed, 23 May 2018 17:11:35 +1200 > > > > > In an ideal world (and I believe the Mac port has gone this way) we > > > would put the NSApp run loop in one thread, and Emacs lisp in another > > > and let them communicate with each other asynchronously. This wouldn’t > > > solve everything, but it would make some of our problems easier. > > FWIW, that's what the w32 port does. > > > > We can’t easily do that, though, as the inter‐thread communication > > > systems provided in Objective‐C are either a pain to implement with > > > complex types like Lisp_Object, or aren’t compatible with GCC and/or > > > GNUstep (Grand Central Dispatch). > > Why do you need to have the communications between the threads be in > terms of Lisp objects? In the w32 port, they communicate in C > objects, and the communications pipe is the read_socket_hook. So in a > nutshell, the GUI event thread sends input to the Lisp interpreter as > if it was the other end of a socket through which window-system > events, including keyboard, mouse, and everything else, are coming. The NS port is similar, it executes the NS run loop within ns_read_socket, and it sends events to the Lisp interpreter. The main problem I have is things coming in the opposite direction. I don’t know if W32 is the same, but we can only run GUI related code in the main thread. If we separate the Lisp thread and the NS run loop thread, then code called from Lisp can’t directly interact with the NS GUI code, it has to be dispatched to the NS run loop thread. If we do this we’ll have to use performSelectorOnMainThread, which calls a method or function on the main thread, but only allows you to pass a single parameter. I believe it’s possible to serialise multiple arguments into a single one, but I’ve no idea if that’s practical. I think this is possible, but will probably require a fair amount of work. It’s also possible I’m over‐complicating this. I feel rather out of my depth. -- Alan Third