From c82c8bdf9b2f92d3c461f4764e202597cd8a2dce Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 20 Jul 2009 23:50:19 +0000 Subject: [PATCH] We need to cancel ourselves before we're posted to the RunQueue and in order to preserve Interval's behavior of not executing an interval that was canceled after it was posted to its runqueue but before it was executed we have to do some nested craziness. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5882 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/server/PresentsDObjectMgr.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/presents/server/PresentsDObjectMgr.java b/src/java/com/threerings/presents/server/PresentsDObjectMgr.java index 08301bf4a..87f46147a 100644 --- a/src/java/com/threerings/presents/server/PresentsDObjectMgr.java +++ b/src/java/com/threerings/presents/server/PresentsDObjectMgr.java @@ -279,10 +279,19 @@ public class PresentsDObjectMgr // from interface RootDObjectManager public Interval newInterval (final Runnable action) { - return new Interval(this) { + return new Interval() { public void expired () { if (isRunning()) { - action.run(); + postRunnable(new Runnable() { + public void run () { + // if we were canceled between the time that we posted this runnable + // and the time the dobjmgr got around to executing us, we opt not to + // actually execute our runnable because that's how Interval does it + if (_task != null) { + action.run(); + } + } + }); } else { cancel(); }