Example usage for io.netty.buffer CompositeByteBuf isReadable

List of usage examples for io.netty.buffer CompositeByteBuf isReadable

Introduction

In this page you can find the example usage for io.netty.buffer CompositeByteBuf isReadable.

Prototype

@Override
    public boolean isReadable() 

Source Link

Usage

From source file:io.servicecomb.foundation.vertx.tcp.TcpConnection.java

License:Apache License

protected void writeInContext() {
    CompositeByteBuf cbb = ByteBufAllocator.DEFAULT.compositeBuffer();
    for (;;) {//  ww w  .  j ava2  s  .  c om
        ByteBuf buf = writeQueue.poll();
        if (buf == null) {
            break;
        }

        writeQueueSize.decrementAndGet();
        cbb.addComponent(true, buf);

        if (cbb.numComponents() == cbb.maxNumComponents()) {
            netSocket.write(Buffer.buffer(cbb));
            cbb = ByteBufAllocator.DEFAULT.compositeBuffer();
        }
    }
    if (cbb.isReadable()) {
        netSocket.write(Buffer.buffer(cbb));
    }
}