protected void cancelTimeout() { final AsyncContextEvent event; try (Locker.Lock lock = _locker.lock()) { event = _event; } cancelTimeout(event); }
public void complete() { // just like resume, except don't set _dispatched=true; boolean handle = false; AsyncContextEvent event; try (Locker.Lock lock = _locker.lock()) { if (DEBUG) LOG.debug("complete {}", toStringLocked()); boolean started = false; event = _event; switch (_async) { case STARTED: started = true; break; case EXPIRING: case ERRORING: case ERRORED: break; case COMPLETE: return; default: throw new IllegalStateException(this.getStatusStringLocked()); } _async = Async.COMPLETE; if (started && _state == State.ASYNC_WAIT) { handle = true; _state = State.ASYNC_WOKEN; } } cancelTimeout(event); if (handle) runInContext(event, _channel); }
public void errorComplete() { try (Locker.Lock lock = _locker.lock()) { if (DEBUG) LOG.debug("error complete {}", toStringLocked()); _async = Async.COMPLETE; _event.setDispatchContext(null); _event.setDispatchPath(null); } cancelTimeout(); }
public void dispatch(ServletContext context, String path) { boolean dispatch = false; AsyncContextEvent event; try (Locker.Lock lock = _locker.lock()) { if (DEBUG) LOG.debug("dispatch {} -> {}", toStringLocked(), path); boolean started = false; event = _event; switch (_async) { case STARTED: started = true; break; case EXPIRING: case ERRORING: case ERRORED: break; default: throw new IllegalStateException(this.getStatusStringLocked()); } _async = Async.DISPATCH; if (context != null) _event.setDispatchContext(context); if (path != null) _event.setDispatchPath(path); if (started) { switch (_state) { case DISPATCHED: case ASYNC_IO: case ASYNC_WOKEN: break; case ASYNC_WAIT: _state = State.ASYNC_WOKEN; dispatch = true; break; default: LOG.warn("async dispatched when complete {}", this); break; } } } cancelTimeout(event); if (dispatch) scheduleDispatch(); }
public void upgrade() { cancelTimeout(); try (Locker.Lock lock = _locker.lock()) { if (DEBUG) LOG.debug("upgrade {}", toStringLocked()); switch (_state) { case IDLE: case COMPLETED: break; default: throw new IllegalStateException(getStatusStringLocked()); } _asyncListeners = null; _state = State.UPGRADED; _async = null; _initial = true; _asyncReadPossible = _asyncReadUnready = false; _asyncWrite = false; _timeoutMs = DEFAULT_TIMEOUT; _event = null; } }
protected void recycle() { cancelTimeout(); try (Locker.Lock lock = _locker.lock()) { if (DEBUG) LOG.debug("recycle {}", toStringLocked()); switch (_state) { case DISPATCHED: case ASYNC_IO: throw new IllegalStateException(getStatusStringLocked()); case UPGRADED: return; default: break; } _asyncListeners = null; _state = State.IDLE; _async = null; _initial = true; _asyncReadPossible = _asyncReadUnready = false; _asyncWrite = false; _timeoutMs = DEFAULT_TIMEOUT; _event = null; } }