A separate thread periodically tests the queue for alarms ready.
71727374757677
private MailService _mailService = new MailService(); public BamMailService() { _alarm = new Alarm(this); }
979899100101102103104105106107108109110111
QueryCallback callback, long timeout) { _queryMap.add(id, callback, timeout); Alarm alarm = _alarm; long expireTime = timeout + Alarm.getCurrentTime(); if (alarm != null && (! alarm.isQueued() || expireTime < alarm.getWakeTime())) { alarm.queueAt(expireTime); } }
180181182183184185186187188189190
_queryMap.checkTimeout(now); } public void close() { Alarm alarm = _alarm; _alarm = null; if (alarm != null) alarm.dequeue(); }
885886887888889890891892893894895
@PostConstruct public void init() throws ServletException { if (_runAt != null || _cron != null) { _alarm = new Alarm(this); } if (_servletName != null) { } else if (getServletNameDefault() != null) {
1042104310441045104610471048104910501051
log.log(Level.WARNING, e.toString(), e); } finally { long now = Alarm.getCurrentTime(); long nextTime = nextTimeout(now); Alarm nextAlarm = _alarm; if (nextAlarm != null) alarm.queue(nextTime - now); } }
140914101411141214131414141514161417141814191420142114221423
void killServlet() { Object servlet = _servlet; _servlet = null; Alarm alarm = _alarm; _alarm = null; if (alarm != null) alarm.dequeue(); if (_comp != null) _comp.preDestroy(servlet); if (servlet instanceof Servlet) {
11351136113711381139114011411142114311441145
enable(); _launcher.start(); _suspendAlarm = new Alarm(new SuspendReaper()); _suspendAlarm.queue(_suspendReaperTimeout); isValid = true; } finally { if (! isValid)
157215731574157515761577157815791580158115821583158415851586
if (log.isLoggable(Level.FINE)) log.fine(this + " closing"); _launcher.destroy(); Alarm suspendAlarm = _suspendAlarm; _suspendAlarm = null; if (suspendAlarm != null) suspendAlarm.dequeue(); QServerSocket serverSocket = _serverSocket; _serverSocket = null; _selectManager = null;
153154155156157158159
TransactionImpl(TransactionManagerImpl manager) { _transactionManager = manager; _timeout = _transactionManager.getTimeout(); _status = Status.STATUS_NO_TRANSACTION; _alarm = new Alarm("xa-timeout", this, ClassLoader.getSystemClassLoader()); }
855856857858859860861862863864865
synchronized (_logLock) { closeLogStream(); } Alarm alarm = _rolloverAlarm; _rolloverAlarm = null; if (alarm != null) alarm.dequeue(); }