unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Repeating timers and suspending the computer
Date: Sun, 11 Dec 2022 08:52:21 +0200	[thread overview]
Message-ID: <83pmcqv3dm.fsf@gnu.org> (raw)
In-Reply-To: <87ilijdjls.fsf@mbork.pl> (message from Marcin Borkowski on Sat,  10 Dec 2022 22:39:11 +0100)

> 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	other threads:[~2022-12-11  6:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-09  5:20 Repeating timers and suspending the computer Marcin Borkowski
2022-12-09  7:25 ` Eli Zaretskii
2022-12-10  4:48   ` Emanuel Berg
2022-12-10 21:39   ` Marcin Borkowski
2022-12-11  6:52     ` Eli Zaretskii [this message]
2022-12-13  5:16       ` Marcin Borkowski
2022-12-13 12:32         ` Eli Zaretskii
2022-12-14 20:13           ` Marcin Borkowski
2022-12-15  6:11             ` Eli Zaretskii
2022-12-15 15:28               ` Marcin Borkowski

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=83pmcqv3dm.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /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.
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).