From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tomohiro Matsuyama Newsgroups: gmane.emacs.devel Subject: Re: Timer scheduling and cancel-timer Date: Sun, 31 Mar 2013 20:17:46 +0900 Message-ID: <20130331201746.cbb41f66c98d4c2be5ad4287@cx4a.org> References: <20130121005802.c7383f4994ead287e738f96f@cx4a.org> <50FC43DB.6070505@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1364728699 26865 80.91.229.3 (31 Mar 2013 11:18:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 31 Mar 2013 11:18:19 +0000 (UTC) Cc: emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 31 13:18:46 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UMGHb-0002NP-J9 for ged-emacs-devel@m.gmane.org; Sun, 31 Mar 2013 13:18:43 +0200 Original-Received: from localhost ([::1]:43971 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMGHD-0002CP-4o for ged-emacs-devel@m.gmane.org; Sun, 31 Mar 2013 07:18:19 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMGH9-0002CG-5o for emacs-devel@gnu.org; Sun, 31 Mar 2013 07:18:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMGH7-00016F-NN for emacs-devel@gnu.org; Sun, 31 Mar 2013 07:18:15 -0400 Original-Received: from www6399u.sakura.ne.jp ([59.106.183.193]:53907 helo=cx4a.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMGH7-00015I-D8 for emacs-devel@gnu.org; Sun, 31 Mar 2013 07:18:13 -0400 Original-Received: from pine (p10047-ipngn1901hodogaya.kanagawa.ocn.ne.jp [180.11.3.47]) by cx4a.org (Postfix) with ESMTPSA id 1959B86D7A; Sun, 31 Mar 2013 20:18:07 +0900 (JST) In-Reply-To: <50FC43DB.6070505@cs.ucla.edu> X-Mailer: Sylpheed 3.2.0 (GTK+ 2.24.10; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 59.106.183.193 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:158493 Archived-At: > 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