public void recycle() { if (context != null) { context.getController().returnContext(context); } context = null; }
serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT); ctx.getController().notifyReady(); } catch (SocketException ex){ throw new BindException(ex.getMessage() + ": " + port + "=" + this);
/** * 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); } /**
ctx.getController().notifyReady(); } catch( SocketException ex ) { throw new BindException( ex.getMessage() + ": " + getPort() );
/** * Polls {@link Context} from pool and initializes it. * * @param serverContext {@link Controller} context * @param key {@link SelectionKey} * @return {@link Context} */ protected Context pollContext(final Context serverContext, final SelectionKey key, final Context.OpType opType) { ProtocolChain protocolChain = instanceHandler != null ? instanceHandler.poll() : serverContext.getController().getProtocolChainInstanceHandler().poll(); final Context context = serverContext.getController().pollContext(key, opType); context.setSelectionKey(key); context.setSelectorHandler(this); context.setAsyncQueueReader(asyncQueueReader); context.setAsyncQueueWriter(asyncQueueWriter); context.setProtocolChain(protocolChain); return context; }
ctx.getController().notifyReady(); } catch (SocketException ex){ throw new BindException(ex.getMessage() + ": " + port);
WorkerThread wt = (WorkerThread)Thread.currentThread(); ByteBuffer bb = wt.getByteBuffer(); controller = ctx.getController();