Search in sources :

Example 6 with ContextImpl

use of io.vertx.core.impl.ContextImpl in project vert.x by eclipse.

the class VertxHandler method channelRead.

@Override
public void channelRead(ChannelHandlerContext chctx, Object msg) throws Exception {
    Object message = safeObject(msg, chctx.alloc());
    C connection = getConnection();
    ContextImpl context;
    if (connection != null) {
        context = getContext(connection);
        context.executeFromIO(connection::startRead);
    } else {
        context = null;
    }
    channelRead(connection, context, chctx, message);
}
Also used : ContextImpl(io.vertx.core.impl.ContextImpl)

Example 7 with ContextImpl

use of io.vertx.core.impl.ContextImpl in project vert.x by eclipse.

the class AsyncFileImpl method doClose.

private void doClose(Handler<AsyncResult<Void>> handler) {
    ContextImpl handlerContext = vertx.getOrCreateContext();
    handlerContext.executeBlocking(res -> {
        try {
            ch.close();
            res.complete(null);
        } catch (IOException e) {
            res.fail(e);
        }
    }, handler);
}
Also used : IOException(java.io.IOException) ContextImpl(io.vertx.core.impl.ContextImpl)

Example 8 with ContextImpl

use of io.vertx.core.impl.ContextImpl in project vert.x by eclipse.

the class HttpServerImpl method actualClose.

private void actualClose(final ContextImpl closeContext, final Handler<AsyncResult<Void>> done) {
    if (id != null) {
        vertx.sharedHttpServers().remove(id);
    }
    ContextImpl currCon = vertx.getContext();
    for (ServerConnection conn : connectionMap.values()) {
        conn.close();
    }
    for (Http2ServerConnection conn : connectionMap2.values()) {
        conn.close();
    }
    // Sanity check
    if (vertx.getContext() != currCon) {
        throw new IllegalStateException("Context was changed");
    }
    if (metrics != null) {
        metrics.close();
    }
    ChannelGroupFuture fut = serverChannelGroup.close();
    fut.addListener(cgf -> executeCloseDone(closeContext, done, fut.cause()));
}
Also used : ChannelGroupFuture(io.netty.channel.group.ChannelGroupFuture) ContextImpl(io.vertx.core.impl.ContextImpl)

Example 9 with ContextImpl

use of io.vertx.core.impl.ContextImpl in project vert.x by eclipse.

the class Http1xPool method requestEnded.

void requestEnded(ClientConnection conn) {
    ContextImpl context = conn.getContext();
    context.runOnContext(v -> {
        if (pipelining && conn.getOutstandingRequestCount() < pipeliningLimit) {
            recycle(conn);
        }
    });
}
Also used : ContextImpl(io.vertx.core.impl.ContextImpl)

Example 10 with ContextImpl

use of io.vertx.core.impl.ContextImpl in project vert.x by eclipse.

the class Http1xPool method responseEnded.

void responseEnded(ClientConnection conn, boolean close) {
    if (!keepAlive || close) {
        conn.close();
    } else {
        ContextImpl ctx = conn.getContext();
        ctx.runOnContext(v -> {
            if (conn.getCurrentRequest() == null) {
                recycle(conn);
            }
        });
    }
}
Also used : ContextImpl(io.vertx.core.impl.ContextImpl)

Aggregations

ContextImpl (io.vertx.core.impl.ContextImpl)13 ByteBuf (io.netty.buffer.ByteBuf)2 Channel (io.netty.channel.Channel)2 ChannelGroupFuture (io.netty.channel.group.ChannelGroupFuture)2 AsyncResult (io.vertx.core.AsyncResult)2 Future (io.vertx.core.Future)2 Handler (io.vertx.core.Handler)2 Buffer (io.vertx.core.buffer.Buffer)2 VertxInternal (io.vertx.core.impl.VertxInternal)2 Logger (io.vertx.core.logging.Logger)2 LoggerFactory (io.vertx.core.logging.LoggerFactory)2 IOException (java.io.IOException)2 Bootstrap (io.netty.bootstrap.Bootstrap)1 Unpooled (io.netty.buffer.Unpooled)1 ChannelFuture (io.netty.channel.ChannelFuture)1 ChannelOption (io.netty.channel.ChannelOption)1 ChannelPipeline (io.netty.channel.ChannelPipeline)1 FixedRecvByteBufAllocator (io.netty.channel.FixedRecvByteBufAllocator)1 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)1 io.netty.handler.codec.http (io.netty.handler.codec.http)1