io.netty.buffer.ByteBuf.isReadOnly()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中io.netty.buffer.ByteBuf.isReadOnly()方法的一些代码示例,展示了ByteBuf.isReadOnly()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.isReadOnly()方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:isReadOnly

ByteBuf.isReadOnly介绍

[英]Returns true if and only if this buffer is read-only.
[中]当且仅当此缓冲区为只读时返回true。

代码示例

代码示例来源:origin: netty/netty

@Override
public boolean isReadOnly() {
  return buf.isReadOnly();
}

代码示例来源:origin: netty/netty

@Override
public boolean isReadOnly() {
  return buf.isReadOnly();
}

代码示例来源:origin: redisson/redisson

@Override
public boolean isReadOnly() {
  return buf.isReadOnly();
}

代码示例来源:origin: redisson/redisson

@Override
public boolean isReadOnly() {
  return buf.isReadOnly();
}

代码示例来源:origin: wildfly/wildfly

@Override
public boolean isReadOnly() {
  return buf.isReadOnly();
}

代码示例来源:origin: wildfly/wildfly

@Override
public boolean isReadOnly() {
  return buf.isReadOnly();
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public boolean isReadOnly() {
  return byteBuf.isReadOnly();
}

代码示例来源:origin: netty/netty

@Override
public boolean isReadOnly() {
  return unwrap().isReadOnly();
}

代码示例来源:origin: redisson/redisson

@Override
public boolean isReadOnly() {
  return unwrap().isReadOnly();
}

代码示例来源:origin: wildfly/wildfly

@Override
public boolean isReadOnly() {
  return unwrap().isReadOnly();
}

代码示例来源:origin: netty/netty

@Override
public ByteBuf asReadOnly() {
  return buf.isReadOnly() ? this : new UnreleasableByteBuf(buf.asReadOnly());
}

代码示例来源:origin: netty/netty

@Override
  public ByteBuf cumulate(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf in) {
    try {
      final ByteBuf buffer;
      if (cumulation.writerIndex() > cumulation.maxCapacity() - in.readableBytes()
        || cumulation.refCnt() > 1 || cumulation.isReadOnly()) {
        // Expand cumulation (by replace it) when either there is not more room in the buffer
        // or if the refCnt is greater then 1 which may happen when the user use slice().retain() or
        // duplicate().retain() or if its read-only.
        //
        // See:
        // - https://github.com/netty/netty/issues/2327
        // - https://github.com/netty/netty/issues/1764
        buffer = expandCumulation(alloc, cumulation, in.readableBytes());
      } else {
        buffer = cumulation;
      }
      buffer.writeBytes(in);
      return buffer;
    } finally {
      // We must release in in all cases as otherwise it may produce a leak if writeBytes(...) throw
      // for whatever release (for example because of OutOfMemoryError)
      in.release();
    }
  }
};

代码示例来源:origin: redisson/redisson

/**
 * Fills the {@link ByteBuf} with zero bytes.
 */
static void zeroout(ByteBuf buffer) {
  if (!buffer.isReadOnly()) {
    buffer.setZero(0, buffer.capacity());
  }
}

代码示例来源:origin: redisson/redisson

@Override
public ByteBuf asReadOnly() {
  return buf.isReadOnly() ? this : new UnreleasableByteBuf(buf.asReadOnly());
}

代码示例来源:origin: redisson/redisson

@Override
  public ByteBuf cumulate(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf in) {
    try {
      final ByteBuf buffer;
      if (cumulation.writerIndex() > cumulation.maxCapacity() - in.readableBytes()
        || cumulation.refCnt() > 1 || cumulation.isReadOnly()) {
        // Expand cumulation (by replace it) when either there is not more room in the buffer
        // or if the refCnt is greater then 1 which may happen when the user use slice().retain() or
        // duplicate().retain() or if its read-only.
        //
        // See:
        // - https://github.com/netty/netty/issues/2327
        // - https://github.com/netty/netty/issues/1764
        buffer = expandCumulation(alloc, cumulation, in.readableBytes());
      } else {
        buffer = cumulation;
      }
      buffer.writeBytes(in);
      return buffer;
    } finally {
      // We must release in in all cases as otherwise it may produce a leak if writeBytes(...) throw
      // for whatever release (for example because of OutOfMemoryError)
      in.release();
    }
  }
};

代码示例来源:origin: wildfly/wildfly

/**
 * Fills the {@link ByteBuf} with zero bytes.
 */
static void zeroout(ByteBuf buffer) {
  if (!buffer.isReadOnly()) {
    buffer.setZero(0, buffer.capacity());
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public ByteBuf asReadOnly() {
  return buf.isReadOnly() ? this : new UnreleasableByteBuf(buf.asReadOnly());
}

代码示例来源:origin: wildfly/wildfly

@Override
  public ByteBuf cumulate(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf in) {
    final ByteBuf buffer;
    if (cumulation.writerIndex() > cumulation.maxCapacity() - in.readableBytes()
        || cumulation.refCnt() > 1 || cumulation.isReadOnly()) {
      // Expand cumulation (by replace it) when either there is not more room in the buffer
      // or if the refCnt is greater then 1 which may happen when the user use slice().retain() or
      // duplicate().retain() or if its read-only.
      //
      // See:
      // - https://github.com/netty/netty/issues/2327
      // - https://github.com/netty/netty/issues/1764
      buffer = expandCumulation(alloc, cumulation, in.readableBytes());
    } else {
      buffer = cumulation;
    }
    buffer.writeBytes(in);
    in.release();
    return buffer;
  }
};

代码示例来源:origin: io.netty/netty-buffer

@Override
public boolean isReadOnly() {
  return buf.isReadOnly();
}

代码示例来源:origin: io.netty/netty-handler

/**
 * Fills the {@link ByteBuf} with zero bytes.
 */
static void zeroout(ByteBuf buffer) {
  if (!buffer.isReadOnly()) {
    buffer.setZero(0, buffer.capacity());
  }
}

相关文章

ByteBuf类方法