public NioChannelHandler.Result onSelect(NioBatchExecutor exec, NioFiberImpl fiber, NioControls controls, SelectionKey key) { int size = handlers.size(); for (int i = 0; i < size; i++) { final NioChannelHandler handler = this.handlers.get(i); final boolean interested = (key.readyOps() & handler.getInterestSet()) != 0; if (interested) { NioChannelHandler.Result result = exec.runOnSelect(fiber, handler, controls, key); switch (result) { case RemoveHandler: if (handlers.size() > 1) { handlers.remove(i--); handler.onEnd(); size--; removeInterestFrom(handler, key); } else { //if no handlers left then the key is going to be cancelled and removed //does not automatically close the socket return NioChannelHandler.Result.RemoveHandler; } break; case CloseSocket: return NioChannelHandler.Result.CloseSocket; } } } return handlers.isEmpty() ? NioChannelHandler.Result.RemoveHandler : NioChannelHandler.Result.Continue; }
public NioChannelHandler.Result onSelect(NioBatchExecutor exec, NioFiberImpl fiber, NioControls controls, SelectionKey key) { int size = handlers.size(); for (int i = 0; i < size; i++) { final NioChannelHandler handler = this.handlers.get(i); final boolean interested = (key.readyOps() & handler.getInterestSet()) != 0; if (interested) { NioChannelHandler.Result result = exec.runOnSelect(fiber, handler, controls, key); switch (result) { case RemoveHandler: if (handlers.size() > 1) { handlers.remove(i--); handler.onEnd(); size--; removeInterestFrom(handler, key); } else { //if no handlers left then the key is going to be cancelled and removed //does not automatically close the socket return NioChannelHandler.Result.RemoveHandler; } break; case CloseSocket: return NioChannelHandler.Result.CloseSocket; } } } return handlers.isEmpty() ? NioChannelHandler.Result.RemoveHandler : NioChannelHandler.Result.Continue; }