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:
@@ -35,7 +35,6 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import com.samskivert.util.Interval;
|
||||
import com.samskivert.util.Lifecycle;
|
||||
import com.samskivert.util.ObserverList;
|
||||
import com.samskivert.util.StringUtil;
|
||||
@@ -337,13 +336,13 @@ public class ClientManager
|
||||
// from interface Lifecycle.Component
|
||||
public void init ()
|
||||
{
|
||||
// start up an interval that will check for and flush expired sessions
|
||||
_flushSessions = new Interval(_omgr) {
|
||||
@Override public void expired () {
|
||||
// start up an interval that will check for and flush expired sessions (this will be
|
||||
// canceled when the omgr shuts down)
|
||||
_omgr.newInterval(new Runnable() {
|
||||
public void run () {
|
||||
flushSessions();
|
||||
}
|
||||
};
|
||||
_flushSessions.schedule(SESSION_FLUSH_INTERVAL, true);
|
||||
}).schedule(SESSION_FLUSH_INTERVAL, true);
|
||||
}
|
||||
|
||||
// from interface Lifecycle.Component
|
||||
@@ -351,8 +350,6 @@ public class ClientManager
|
||||
{
|
||||
log.info("Client manager shutting down", "ccount", _usermap.size());
|
||||
|
||||
_flushSessions.cancel();
|
||||
|
||||
// inform all of our clients that they are being shut down
|
||||
synchronized (_usermap) {
|
||||
for (PresentsSession pc : _usermap.values()) {
|
||||
@@ -625,9 +622,6 @@ public class ClientManager
|
||||
/** Tracks registered {@link ClientObserver}s. */
|
||||
protected ObserverList<ClientObserver> _clobservers = ObserverList.newSafeInOrder();
|
||||
|
||||
/** Interval to flush expired sessions. */
|
||||
protected Interval _flushSessions;
|
||||
|
||||
// our injected dependencies
|
||||
@Inject protected PresentsDObjectMgr _omgr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user