From: Paul Eggert <eggert@cs.ucla.edu>
To: Tomohiro Matsuyama <tomo@cx4a.org>
Cc: emacs-devel@gnu.org
Subject: Re: Timer scheduling and cancel-timer
Date: Sun, 20 Jan 2013 11:22:03 -0800 [thread overview]
Message-ID: <50FC43DB.6070505@cs.ucla.edu> (raw)
In-Reply-To: <20130121005802.c7383f4994ead287e738f96f@cx4a.org>
On 01/20/2013 07:58 AM, Tomohiro Matsuyama wrote:
> (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.
Hmm, isn't that due to a race in the above code?
A timer can fire when a timer action is running.
Do you get zombie timers with the following?
It should avoid the race.
(setq my-timer
(run-with-timer
nil 0.1
(lambda ()
(let ((m my-timer))
(when m
(cancel-timer m)
(setq my-timer nil)
(sit-for 0.3))))))
next prev parent reply other threads:[~2013-01-20 19:22 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 [this message]
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
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=50FC43DB.6070505@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
--cc=tomo@cx4a.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.