From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: Re: run-with-timer vs run-with-idle-timer Date: Sat, 12 May 2018 19:37:45 +0200 Message-ID: <87in7s7p1y.fsf@gnuvola.org> References: <87tvrgd972.fsf@gmail.com> <87a7t74tsf.fsf@gnuvola.org> <87603v4a5x.fsf@gnuvola.org> <871seiqxwr.fsf@gmail.com> Reply-To: emacs-devel NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1526147486 3038 195.159.176.226 (12 May 2018 17:51:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 12 May 2018 17:51:26 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 12 19:51:22 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 1fHYfy-0000fs-4R for ged-emacs-devel@m.gmane.org; Sat, 12 May 2018 19:51:22 +0200 Original-Received: from localhost ([::1]:60160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHYi3-0006xd-IG for ged-emacs-devel@m.gmane.org; Sat, 12 May 2018 13:53:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHYgx-0006ky-77 for emacs-devel@gnu.org; Sat, 12 May 2018 13:52:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHYgs-0000yg-Dy for emacs-devel@gnu.org; Sat, 12 May 2018 13:52:23 -0400 Original-Received: from mail.agora-net.com ([67.59.132.6]:57940) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fHYgs-0000xX-7g for emacs-devel@gnu.org; Sat, 12 May 2018 13:52:18 -0400 Original-Received: from ttn by mail.agora-net.com with local (Exim 4.82) (envelope-from ) id 1fHYgq-0007nL-NY; Sat, 12 May 2018 13:52:16 -0400 Original-Received: from ttn by zigzag.favinet with local (Exim 4.80) (envelope-from ) id 1fHYT2-0001kx-Hu; Sat, 12 May 2018 19:38:00 +0200 Mail-Followup-To: emacs-devel In-Reply-To: <871seiqxwr.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Fri, 11 May 2018 11:39:16 +0100") X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: ttn@gnuvola.org X-SA-Exim-Scanned: No (on mail.agora-net.com); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 67.59.132.6 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:225272 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable () Jo=C3=A3o T=C3=A1vora () Fri, 11 May 2018 11:39:16 +0100 After thinking a bit about it, you're totally right, and it becomes much simpler (read below). Cool, simpler (if it still works) is better. > I suppose it's a matter of style. Maybe not, maybe [while CONDITION] is indeed more efficient, since it amounts to far fewer calls to accept-process-output. It's less efficient up until the point CONDITION is no longer satisfied (since it has to compute/check CONDITION). But past that point, it's infinitely more efficient for the reason you give. > able to play multiple games simultaneously (i.e., run > multiple independent child processes), and greedily > spinning borks that. Since from Emacs's perspective we're both blocking, you must mean that you have less CPU available for the subprocesses, right? I don't really know what i meant, actually. I think it was just my ego trying to sound bigger than my memory would permit. You will forgive the fool curmudgeon a lapse here and there, right? It's been a long time since i used the verb "bork"... /pleading The truth is that =E2=80=98gnugo--q=E2=80=99 is synchronous by design (it s= ays so right in the comment about =E2=80=98:srs=E2=80=99, after all -- but who = reads comments, anyway?!) and does indeed block (since 1st arg to =E2=80=98accept-process-output=E2=80=99 is specified) until input appears. That said, top-level (user interaction) control only passes to =E2=80=98gnugo--q=E2=80=99 via =E2=80=98run-at-time=E2=80=99, which normall= y fires after two seconds, plenty of time (even on this old computer) for Emacs to move its pointers around. Too, because the action is captured in a timer object, Emacs has even more of a free hand to diddle w/ its scheduling. To sum up, spinning is what is going on, true, but "greedily" maybe not so much. Really, it's more like bowing to the four corners of the earth (once) than spinning... > [...] seeing a skeleton of the code [...] If you haven't yet connected the dots, this is for my new mode eglot.el from the other thread. Ah OK. Sounds interesting! Since it is very new, I think I'm just going to apply your suggestion (diff below). Cool. It works fine and the code becomes tighter, though it still doesn't solve the original problem that makes the idle-timer not kick in in the meantime. (Later, I can explain more about why I need that, and how I'm working around it). OK. =2D-=20 Thien-Thi Nguyen ----------------------------------------------- (defun responsep (query) (pcase (context query) (`(technical ,ml) (correctp ml)) ...)) 748E A0E8 1CB8 A748 9BFA =2D-------------------------------------- 6CE4 6703 2224 4C80 7502 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlr3JnEACgkQZwMiJEyAdQKpuACg5jyS0fqcT8poOrsTajx3oBwB u2oAmQGsZ18vA0T5mf6WNJJyAut51GWk =+x08 -----END PGP SIGNATURE----- --=-=-=--