コード例 #1
0
ファイル: AbstractChannel.java プロジェクト: robbinfan/netty
 private int outboundBufSize() {
   final int bufSize;
   final ChannelHandlerContext ctx = directOutboundContext();
   if (ctx.hasOutboundByteBuffer()) {
     bufSize = ctx.outboundByteBuffer().readableBytes();
   } else {
     bufSize = ctx.outboundMessageBuffer().size();
   }
   return bufSize;
 }
コード例 #2
0
ファイル: AbstractChannel.java プロジェクト: robbinfan/netty
    @Override
    public final void flushNow() {
      if (inFlushNow || flushTaskInProgress != null) {
        return;
      }

      inFlushNow = true;
      ChannelHandlerContext ctx = directOutboundContext();
      Throwable cause = null;
      try {
        if (ctx.hasOutboundByteBuffer()) {
          ByteBuf out = ctx.outboundByteBuffer();
          int oldSize = out.readableBytes();
          try {
            doFlushByteBuffer(out);
          } catch (Throwable t) {
            cause = t;
          } finally {
            final int newSize = out.readableBytes();
            final int writtenBytes = oldSize - newSize;
            if (writtenBytes > 0) {
              flushFutureNotifier.increaseWriteCounter(writtenBytes);
              if (newSize == 0) {
                out.discardReadBytes();
              }
            }
          }
        } else {
          MessageBuf<Object> out = ctx.outboundMessageBuffer();
          int oldSize = out.size();
          try {
            doFlushMessageBuffer(out);
          } catch (Throwable t) {
            cause = t;
          } finally {
            flushFutureNotifier.increaseWriteCounter(oldSize - out.size());
          }
        }

        if (cause == null) {
          flushFutureNotifier.notifyFlushFutures();
        } else {
          flushFutureNotifier.notifyFlushFutures(cause);
          if (cause instanceof IOException) {
            close(voidFuture());
          }
        }
      } finally {
        inFlushNow = false;
      }
    }
コード例 #3
0
 @Override
 public void freeOutboundBuffer(ChannelHandlerContext ctx) {
   ctx.outboundMessageBuffer().free();
 }