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: Marcin Borkowski
Subject: Re: Repeating timers and suspending the computer
Date: Sat, 10 Dec 2022 22:39:11 +0100
User-agent: mu4e 1.1.0; emacs 29.0.50

On 2022-12-09, at 08:25, Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Marcin Borkowski <mbork@mbork.pl>
>> Date: Fri, 09 Dec 2022 06:20:22 +0100
>> 
>> assume that I said
>> 
>> (run-with-timer 0 1
>>                 (lambda () (message "%s" (format-time-string 
>> "%H:%M:%S.%3N"))))
>> 
>> and put my laptop in the "sleep mode" for 20 seconds.  How many time
>> messages should I get?  Assume `timer-max-repeats' is 10 (which seems to
>> be the default).
>> 
>> When I did the experiment, it seemed that the timer'd function was run
>> /twice/ after waking up, which looks really strange -- why two times?
>
> I think you have some implicit mental model of what happens when the

I think so, though it is pretty vague ATM.

> number of delayed invocations of the timer function exceeds that
> limit, a model that you didn't describe.  You seem to be assuming that
> you will get those 10 invocations, and no more, is that right?  But

"Assuming" is probably not the best word.  "Suspecting" might fit
better;-).

> that is not the only possible way of dealing with this situation.  In
> fact, it isn't even smart: if time has jumped far ahead, why should
> Emacs give you 10 useless invocations of the timer?

Well, I can think of some reasons...  (Not to say they are very /good/
reasons.)

> Or if you were expecting something else, please tell what you expected
> and why.

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?

-- 
Marcin Borkowski
http://mbork.pl



reply via email to

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