unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alexander Shukaev <emacs@Alexander.Shukaev.name>
To: Eli Zaretskii <eliz@gnu.org>, Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Temporarily disable `timer-event-handler'
Date: Tue, 4 Feb 2020 23:30:45 +0100	[thread overview]
Message-ID: <feaf06a0-8eb1-18c0-ed74-dcd8030866d6@Alexander.Shukaev.name> (raw)
In-Reply-To: <83wo93hdzh.fsf@gnu.org>

On 03/02/2020 16:44, Eli Zaretskii wrote:
> [I removed help-gnu-emacs from the CC list.]
> 
>> From: Stefan Monnier <monnier@iro.umontreal.ca>
>> Date: Mon, 03 Feb 2020 09:01:47 -0500
>> Cc: help-gnu-emacs@gnu.org, emacs-devel@gnu.org
>>
>>> Finally, what's the motivation behind this design?  This looks fragile and
>>> error-prone to run some arbitrary code in the middle of execution of another
>>> code without separating their "stacks" (environment scopes),
>>
>> It's a direct consequence of the implementation, rather than the result
>> of design, AFAICT.
> 
> There's also the need to run a timer as close to its expected time as
> possible, so waiting for any Lisp to return might delay timers too
> much.
> 

Right, the current implementation looks more like coroutines, where 
certain built-in functions yield for timers to run on occasion.  This is 
indeed likely to be more performent and even useful at times, i.e. 
example from Stefan

> But there can also be cases where A does want/need B to be processed
> before A ends.

Nonetheless, given the availability of dynamic binding, I find this 
error-prone.  Is there currently a way in Emacs Lisp to run a function 
within a separate stack, i.e. free of any "user-defined" dynamic 
bindings?  I would imagine that this may be the right solution to fire 
timer events in this manner as it then does not matter whether they run 
in the middle of other routines.

Additionally, I believe the solution to fulfill

> The expectation is that `B' strictly runs after `A' finishes execution.

is also missing.  Some sort of macro (aka `ignore-timers') which 
essentially forbids yielding during the execution of the enclosed body, 
while `let'-binding both `timer-list' and `timer-idle-list' as a naive 
implementation of such does not really scale, since any inner calls to 
`cancel-timer' or otherwise scheduling other (new) timer events would 
have bad side effects.  Otherwise, should be something simple and 
similar to `inhibit-redisplay', aka `inhibit-timers' and 
`inhibit-idle-timers'.



  reply	other threads:[~2020-02-04 22:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-02 23:25 Temporarily disable `timer-event-handler' Alexander Shukaev
2020-02-03  1:36 ` Drew Adams
2020-02-03  8:23 ` Michael Albinus
2020-02-03 14:01 ` Stefan Monnier
2020-02-03 15:44   ` Eli Zaretskii
2020-02-04 22:30     ` Alexander Shukaev [this message]
2020-02-05  0:53       ` Stefan Monnier
2020-02-05  1:21         ` Alexander Shukaev
2020-02-05  1:30           ` Stefan Monnier
2020-02-05 14:29           ` Eli Zaretskii
2020-02-05 15:09             ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=feaf06a0-8eb1-18c0-ed74-dcd8030866d6@Alexander.Shukaev.name \
    --to=emacs@alexander.shukaev.name \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).