help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Repeating timers and suspending the computer


From: Eli Zaretskii
Subject: Re: Repeating timers and suspending the computer
Date: Sun, 11 Dec 2022 08:52:21 +0200

> From: Marcin Borkowski <mbork@mbork.pl>
> Cc: help-gnu-emacs@gnu.org
> Date: Sat, 10 Dec 2022 22:39:11 +0100
> 
> 
> Frankly, I expected my function to be called either once or 10 times,
> but not twice.
> 
> So, how can I get a better mental model?

By looking at the source, of course.  There you will see that if the
expected number of calls exceeds the limit, Emacs advances the "last
invocation time" of the timer to the current time, thus effectively
bypassing all those delayed invocations.

Why you see 2 calls instead of just the expected one needs more
investigation.  At the very least, it depends on the exact time when
your computer was awoken: if that time was close to the integral
multiple of the timer period, you can legitimately see two invocations
with a very small time interval between them.  But maybe some other
factor is at work here.  If you are really interested, I suggest to
instrument timer.el with some calls to 'message' and repeat the
experiment to learn why that happens.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]