public void recycle() { if (context != null) { context.getController().returnContext(context); } context = null; }
/** * Cancel a {@link #suspend}ed {@link Context}. Invoking this method will * automatically clean the state of this Context and mark it as a candidate * for being re-used by another Thread and connection. * * <strong>Important. When cancelled, all operations done on this * object are not thread-safe and there is probability that another * thread is already using this object. Never use this object once cancelled.</strong> * * * When invoked this method will automatically close the underlying * connection (represented by its {@link SelectionKey}. * * If the Context hasn't been suspended, calling that method has no effet. */ public void cancel(){ if (!isSuspended) return; isSuspended = false; selectorHandler.getSelectionKeyHandler().cancel(key); getController().returnContext(this); } /**