Added RootDObjectManager.newInterval() for creating intervals that are

automatically canceled when the omgr is shutdown (they actually cancel
themselves if they fire after the omgr has been shutdown, which stock intervals
also do, but these guys do so quietly because we know they mean to work that
way).

Made use of that new method and the fluent schedule methods in various places.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5880 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2009-07-20 22:43:00 +00:00
parent 57b630727e
commit c0c68f98d3
8 changed files with 65 additions and 78 deletions
@@ -281,8 +281,12 @@ public abstract class PeerManager
// register ourselves as a client observer
_clmgr.addClientObserver(this);
// and start our peer refresh interval
_peerRefresher.schedule(5000L, 60*1000L);
// and start our peer refresh interval (this lives for the lifetime of the server)
_omgr.newInterval(new Runnable() {
public void run () {
refreshPeers();
}
}).schedule(5000L, 60*1000L);
// give derived classes an easy way to get in on the init action
didInit();
@@ -773,9 +777,6 @@ public abstract class PeerManager
_invmgr.clearDispatcher(_nodeobj.peerService);
}
// stop our peer refresher interval
_peerRefresher.cancel();
// clear out our client observer registration
_clmgr.removeClientObserver(this);
@@ -1187,9 +1188,8 @@ public abstract class PeerManager
_remoids = (ArrayIntSet)_suboids.clone();
// schedule a timeout to act if something goes wrong
(_timeout = new Interval(_omgr) {
@Override
public void expired () {
_timeout = _omgr.newInterval(new Runnable () {
public void run () {
log.warning("Lock handler timed out, acting anyway", "lock", _lock,
"acquire", _acquire);
_stats.lockTimeouts++;
@@ -1372,13 +1372,6 @@ public abstract class PeerManager
}
};
// (this need not use a runqueue as all it will do is post an invoker unit)
protected Interval _peerRefresher = new Interval() {
@Override public void expired () {
refreshPeers();
}
};
protected String _nodeName, _sharedSecret;
protected NodeRecord _self;
protected NodeObject _nodeobj;