From: Michael Heerdegen <michael_heerdegen@web.de>
To: emacs-devel@gnu.org
Cc: Paul Eggert <eggert@cs.ucla.edu>, emacs-devel@gnu.org
Subject: Re: Timer scheduling and cancel-timer
Date: Sun, 31 Mar 2013 18:44:14 +0200 [thread overview]
Message-ID: <87bo9zh63l.fsf@web.de> (raw)
In-Reply-To: <20130331201746.cbb41f66c98d4c2be5ad4287@cx4a.org> (Tomohiro Matsuyama's message of "Sun, 31 Mar 2013 20:17:46 +0900")
Tomohiro Matsuyama <tomo@cx4a.org> writes:
> > > (setq my-timer
> > > (run-with-timer
> > > nil 0.1
> > > (lambda ()
> > > (when my-timer
> > > (cancel-timer my-timer)
> > > (setq my-timer nil)
> > > (sit-for 0.3)))))
> > >
> > > After evaluating this code several times, you may see "zombie" timers
> > > in timer-list, though the code intends to keep at most one timer.
I see that, too.
To reveal what's happening, I ran the following experiment:
--8<---------------cut here---------------start------------->8---
(defvar my-timer nil)
(defun start-the-timer ()
(interactive)
(setq my-timer
(run-with-timer
0 0.1
(lambda ()
(cancel-timer my-timer)
(sit-for 0.3)))))
(advice-add 'timer-event-handler :before
(lambda (timer)
(when (and (eq timer my-timer)
(not (memq my-timer timer-list)))
(message "Why is this ever reached?"))))
--8<---------------cut here---------------end--------------->8---
If you call `start-the-timer', you get the message "Why is this ever
reached?" over and over.
Obviously, although the timer object created has been successfully
canceled (i.e., removed from `timer-list'), the C code still calls it
repeatedly with `timer-event-handler'. Dunno why, but that's not good.
Regards,
Michael.
prev parent reply other threads:[~2013-03-31 16:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-20 15:58 Timer scheduling and cancel-timer Tomohiro Matsuyama
2013-01-20 19:22 ` Paul Eggert
2013-01-20 21:04 ` Drew Adams
2013-01-20 21:35 ` Drew Adams
2013-01-21 1:36 ` Stefan Monnier
2013-01-21 1:39 ` Drew Adams
2013-01-22 3:50 ` Drew Adams
2013-01-22 11:28 ` Stephen Berman
2013-01-22 16:00 ` Stephen Berman
2013-01-22 16:09 ` Bastien
2013-01-23 9:32 ` Bastien
2013-01-23 13:03 ` Stefan Monnier
2013-01-23 13:29 ` Bastien
2013-01-23 20:35 ` Stefan Monnier
2013-01-23 22:01 ` Bastien
2013-01-24 16:32 ` Drew Adams
2013-01-24 19:02 ` Bastien
2013-01-22 13:34 ` Stefan Monnier
2013-01-22 13:57 ` Bastien
2013-01-22 14:14 ` Stefan Monnier
2013-03-31 11:17 ` Tomohiro Matsuyama
2013-03-31 16:44 ` Michael Heerdegen [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bo9zh63l.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=eggert@cs.ucla.edu \
--cc=emacs-devel@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.