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
This commit is contained in:
Michael Bayne
2009-07-20 23:50:19 +00:00
parent 8c2a1d9b37
commit c82c8bdf9b
@@ -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();
}