Package org.xnio

Examples of org.xnio.StreamConnection


    public void exchangeComplete(final HttpServerExchange exchange) {
        connection.clearChannel();
        final HttpServerConnection connection = this.connection;
        if (exchange.isPersistent() && !exchange.isUpgrade()) {
            final StreamConnection channel = connection.getChannel();
            if (connection.getExtraBytes() == null) {
                //if we are not pipelining we just register a listener
                //we have to resume from with the io thread
                while (requestStateUpdater.get(this) != 0) {
                    if (requestStateUpdater.compareAndSet(this, 1, 2)) {
                        newRequest();
                        channel.getSourceChannel().setReadListener(HttpReadListener.this);
                        channel.getSourceChannel().resumeReads();
                        requestStateUpdater.set(this, 0);
                    }
                }
            } else {
                requestStateUpdater.set(this, 0); //no need to CAS, as we don't actually resume
                newRequest();
                if (exchange.isInIoThread()) {
                    //no need to suspend reads here, the task will always run before the read listener anyway
                    channel.getIoThread().execute(this);
                } else {
                    channel.getSourceChannel().suspendReads();
                    Executor executor = exchange.getDispatchExecutor();
                    if (executor == null) {
                        executor = exchange.getConnection().getWorker();
                    }
                    executor.execute(this);
View Full Code Here


    void performFlush(final HttpServerExchange exchange, final HttpServerConnection connection) {
        try {
            final HttpServerConnection.ConduitState oldState = connection.resetChannel();
            if (!flushPipelinedData()) {
                final StreamConnection channel = connection.getChannel();
                channel.getSinkChannel().getWriteSetter().set(new ChannelListener<Channel>() {
                    @Override
                    public void handleEvent(Channel c) {
                        try {
                            if (flushPipelinedData()) {
                                channel.getSinkChannel().getWriteSetter().set(null);
                                channel.getSinkChannel().suspendWrites();
                                connection.restoreChannel(oldState);
                                connection.getReadListener().exchangeComplete(exchange);
                            }
                        } catch (IOException e) {
                            UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
View Full Code Here

TOP

Related Classes of org.xnio.StreamConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.