Better interval behavior.

If no runqueue is supplied on which to prune sessions, we don't schedule a
session pruner, rather than scheduling a long running database action on the
Interval timer thread, thereby booching all other Intervals.
This commit is contained in:
Michael Bayne
2011-06-17 12:23:09 -07:00
parent 4a53f9c29b
commit 85efd40adf
@@ -124,7 +124,8 @@ public class UserManager
} }
// register a cron job to prune the session table every hour // register a cron job to prune the session table every hour
_pruner = new Interval() { if (pruneQueue != null) {
_pruner = new Interval(pruneQueue) {
@Override public void expired () { @Override public void expired () {
try { try {
_repository.pruneSessions(); _repository.pruneSessions();
@@ -133,17 +134,17 @@ public class UserManager
} }
} }
}; };
if (pruneQueue != null) {
_pruner.setRunQueue(pruneQueue);
}
_pruner.schedule(SESSION_PRUNE_INTERVAL, true); _pruner.schedule(SESSION_PRUNE_INTERVAL, true);
} }
}
public void shutdown () public void shutdown ()
{ {
// cancel our session table pruning thread // cancel our session table pruning thread
if (_pruner != null) {
_pruner.cancel(); _pruner.cancel();
} }
}
/** /**
* Returns a reference to the repository in use by this user manager. * Returns a reference to the repository in use by this user manager.