Timers: Improve OutboundMessageRegistry locking

SimpleTimer2 cleanups
possible fix for ticket #1694
This commit is contained in:
zzz
2015-11-04 14:57:07 +00:00
parent ef428d559e
commit b15ea8ba2f
2 changed files with 17 additions and 11 deletions

View File

@ -416,13 +416,15 @@ public class SimpleTimer2 {
case IDLE: // fall through
case RUNNING:
throw new IllegalStateException(this + " not possible to be in " + _state);
case SCHEDULED: // proceed, switch to IDLE in case I need to reschedule
_state = TimedEventState.IDLE;
case SCHEDULED:
// proceed, will switch to IDLE to reschedule
}
// if I was rescheduled by the user, re-submit myself to the executor.
int difference = (int)(_nextRun - before); // careful with long uptimes
long difference = _nextRun - before; // careful with long uptimes
if (difference > _fuzz) {
// proceed, switch to IDLE to reschedule
_state = TimedEventState.IDLE;
schedule(difference);
return;
}
@ -437,10 +439,12 @@ public class SimpleTimer2 {
else if (_log.shouldLog(Log.WARN))
_log.warn(_pool + " no _future " + this);
// This can be an incorrect warning especially after a schedule(0)
if (_log.shouldLog(Log.WARN) && delay > 100)
_log.warn(_pool + " early execution " + delay + ": " + this);
else if (_log.shouldLog(Log.WARN) && delay < -1000)
_log.warn(" late execution " + (0 - delay) + ": " + this + _pool.debug());
if (_log.shouldWarn()) {
if (delay > 100)
_log.warn(_pool + " early execution " + delay + ": " + this);
else if (delay < -1000)
_log.warn(" late execution " + (0 - delay) + ": " + this + _pool.debug());
}
try {
timeReached();
} catch (Throwable t) {