[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Timer scheduling and cancel-timer
From: |
Tomohiro Matsuyama |
Subject: |
Re: Timer scheduling and cancel-timer |
Date: |
Sun, 31 Mar 2013 20:17:46 +0900 |
> 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))))))
I still got zombie timers. Same if I replace sit-for with sleep-for.
No one can reproduce this problem?
Regards,
Tomohiro
- Re: Timer scheduling and cancel-timer,
Tomohiro Matsuyama <=