From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Questions about throw-on-input Date: Fri, 08 May 2020 14:45:35 +0300 Message-ID: <83imh6ira8.fsf@gnu.org> References: <87r1vwxktw.fsf@gmail.com> <831rnvly58.fsf@gnu.org> <83r1vuiu90.fsf@gnu.org> <87v9l67jrd.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="69170"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Ivan Yonchovski Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 08 13:46:45 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 1jX1Sl-000Hqp-VQ for ged-emacs-devel@m.gmane-mx.org; Fri, 08 May 2020 13:46:43 +0200 Original-Received: from localhost ([::1]:39954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX1Sl-0005zr-1K for ged-emacs-devel@m.gmane-mx.org; Fri, 08 May 2020 07:46:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX1Rs-00056z-Mf for emacs-devel@gnu.org; Fri, 08 May 2020 07:45:48 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:54476) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX1Rs-0004YC-CD; Fri, 08 May 2020 07:45:48 -0400 Original-Received: from [176.228.60.248] (port=3394 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jX1Rr-0002Ub-RR; Fri, 08 May 2020 07:45:48 -0400 In-Reply-To: <87v9l67jrd.fsf@gmail.com> (message from Ivan Yonchovski on Fri, 08 May 2020 14:23:34 +0300) 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:249267 Archived-At: > From: Ivan Yonchovski > Cc: emacs-devel@gnu.org > Date: Fri, 08 May 2020 14:23:34 +0300 > > (defun process-events () > (when (input-pending-p) > (run-with-timer 0.01 nil (lambda () (throw 'exit nil))) > (recursive-edit))) > > (dotimes (counter 1000) > (sleep-for 0.01) ;; simulate execution of N tasks > (message "%s" counter) > (process-events)) > > This code is able to handle C-n but obviously it will break if someone > starts another recursive-edit or for complex keybindings, e. g. `C-x b`. I think you will indeed find that this is very fragile. > Are you aware of something doing something similar? Do you think it > makes sense if you want to process something slow on the background > without blocking emacs? I think this is why we added threads to Emacs. Why not try doing this in a thread? > > AFAIU, such facilities need to have a separate event loop that > > generally runs in a separate thread. > > In the C# case it all happens on the UI thread. DoEvents means handle > mouse clicks, repaint controls, etc(the stuff from the event loop) and > then continue with current execution. When display is as intimately connected to the global state as it is in Emacs, I don't think such separation can fly.