org.glassfish.grizzly.Buffer.allowBufferDispose()方法的使用及代码示例

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

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

Buffer.allowBufferDispose介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-dubbo

@Override
public NextAction handleWrite(FilterChainContext context) throws IOException {
  Connection<?> connection = context.getConnection();
  GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler);
  try {
    ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024); // Do not need to close
    Object msg = context.getMessage();
    codec.encode(channel, channelBuffer, msg);
    GrizzlyChannel.removeChannelIfDisconnected(connection);
    Buffer buffer = connection.getTransport().getMemoryManager().allocate(channelBuffer.readableBytes());
    buffer.put(channelBuffer.toByteBuffer());
    buffer.flip();
    buffer.allowBufferDispose(true);
    context.setMessage(buffer);
  } finally {
    GrizzlyChannel.removeChannelIfDisconnected(connection);
  }
  return context.getInvokeAction();
}

代码示例来源:origin: apache/incubator-dubbo

@Override
public NextAction handleWrite(FilterChainContext context) throws IOException {
  Connection<?> connection = context.getConnection();
  GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler);
  try {
    ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024); // Do not need to close
    Object msg = context.getMessage();
    codec.encode(channel, channelBuffer, msg);
    GrizzlyChannel.removeChannelIfDisconnected(connection);
    Buffer buffer = connection.getTransport().getMemoryManager().allocate(channelBuffer.readableBytes());
    buffer.put(channelBuffer.toByteBuffer());
    buffer.flip();
    buffer.allowBufferDispose(true);
    context.setMessage(buffer);
  } finally {
    GrizzlyChannel.removeChannelIfDisconnected(connection);
  }
  return context.getInvokeAction();
}

代码示例来源:origin: com.ning/async-http-client

.last(true)
    .build();
buffer.allowBufferDispose(false);
ctx.write(content, ((!requestPacket.isCommitted()) ? ctx.getTransportContext().getCompletionHandler() : null));

代码示例来源:origin: com.ning/async-http-client

while (!last) {
  Buffer buffer = mm.allocate(PayloadGenerator.MAX_CHUNK_SIZE);
  buffer.allowBufferDispose(true);
  final long readBytes = bodyLocal.read(buffer.toByteBuffer());
  if (readBytes > 0) {

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server-core

private Buffer getHeader() {
  final Buffer headerToWrite = header.duplicate();
  headerToWrite.allowBufferDispose(false);
  return headerToWrite;
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http

private void checkCurrentBuffer() {
  if (currentBuffer == null) {
    currentBuffer = memoryManager.allocate(bufferSize);
    currentBuffer.allowBufferDispose(true);
  }
}

代码示例来源:origin: com.ning/async-http-client

buffer.allowBufferDispose(true);

代码示例来源:origin: javaee/grizzly

private static Buffer allowDispose(final Buffer buffer) {
  buffer.allowBufferDispose(true);
  if (buffer.isComposite()) {
    ((CompositeBuffer) buffer).allowInternalBuffersDispose(true);
  }
  
  return buffer;
}

代码示例来源:origin: javaee/grizzly

public static Buffer allowDispose(final Buffer buffer) {
  if (buffer == null) {
    return null;
  }
  
  buffer.allowBufferDispose(true);
  if (buffer.isComposite()) {
    ((CompositeBuffer) buffer).allowInternalBuffersDispose(true);
  }
  
  return buffer;
}

代码示例来源:origin: javaee/grizzly

public static Buffer getLongAsBuffer(final MemoryManager memoryManager,
                   final long length) {
  final Buffer b = memoryManager.allocate(20);
  b.allowBufferDispose(true);
  HttpUtils.longToBuffer(length, b);
  return b;
}

代码示例来源:origin: javaee/grizzly

public static Buffer allowDispose(final Buffer buffer) {
  if (buffer == null) {
    return null;
  }
  
  buffer.allowBufferDispose(true);
  if (buffer.isComposite()) {
    ((CompositeBuffer) buffer).allowInternalBuffersDispose(true);
  }
  
  return buffer;
}

代码示例来源:origin: javaee/grizzly

private static Buffer allowDispose(final Buffer buffer) {
  buffer.allowBufferDispose(true);
  if (buffer.isComposite()) {
    ((CompositeBuffer) buffer).allowInternalBuffersDispose(true);
  }
  
  return buffer;
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-core

private static Buffer allowDispose(final Buffer buffer) {
  buffer.allowBufferDispose(true);
  if (buffer.isComposite()) {
    ((CompositeBuffer) buffer).allowInternalBuffersDispose(true);
  }
  
  return buffer;
}

代码示例来源:origin: org.mule.glassfish.grizzly/grizzly-framework

public static Buffer allowDispose(final Buffer buffer) {
  if (buffer == null) {
    return null;
  }
  
  buffer.allowBufferDispose(true);
  if (buffer.isComposite()) {
    ((CompositeBuffer) buffer).allowInternalBuffersDispose(true);
  }
  
  return buffer;
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

protected void updateInputContentBuffer(final Buffer buffer)  {
  buffer.allowBufferDispose(true);
  
  if (inputContentBuffer == null) {
    inputContentBuffer = buffer;
  } else if (inputContentBuffer.hasRemaining()
      || readAheadLimit > 0) { // if the stream is marked - we can't dispose the inputContentBuffer, even if it's been read off
    toCompositeInputContentBuffer().append(buffer);
  } else {
    inputContentBuffer.tryDispose();
    inputContentBuffer = buffer;
  }
}

代码示例来源:origin: javaee/grizzly

protected void updateInputContentBuffer(final Buffer buffer)  {
  buffer.allowBufferDispose(true);
  
  if (inputContentBuffer == null) {
    inputContentBuffer = buffer;
  } else if (inputContentBuffer.hasRemaining()
      || readAheadLimit > 0) { // if the stream is marked - we can't dispose the inputContentBuffer, even if it's been read off
    toCompositeInputContentBuffer().append(buffer);
  } else {
    inputContentBuffer.tryDispose();
    inputContentBuffer = buffer;
  }
}

代码示例来源:origin: javaee/grizzly

private static void disposeBuffers(final Buffer currentBuffer, final Buffer bigBuffer) {
  if (currentBuffer != null) {
    currentBuffer.dispose();
  }
  if (bigBuffer != null) {
    bigBuffer.allowBufferDispose(true);
    if (bigBuffer.isComposite()) {
      ((CompositeBuffer) bigBuffer).allowInternalBuffersDispose(true);
    }
    
    bigBuffer.dispose();
  }
}

代码示例来源:origin: javaee/grizzly

private static void disposeBuffers(final Buffer currentBuffer, final Buffer bigBuffer) {
  if (currentBuffer != null) {
    currentBuffer.dispose();
  }
  if (bigBuffer != null) {
    bigBuffer.allowBufferDispose(true);
    if (bigBuffer.isComposite()) {
      ((CompositeBuffer) bigBuffer).allowInternalBuffersDispose(true);
    }
    
    bigBuffer.dispose();
  }
}

代码示例来源:origin: org.mule.glassfish.grizzly/grizzly-framework

private static void disposeBuffers(final Buffer currentBuffer, final Buffer bigBuffer) {
  if (currentBuffer != null) {
    currentBuffer.dispose();
  }
  if (bigBuffer != null) {
    bigBuffer.allowBufferDispose(true);
    if (bigBuffer.isComposite()) {
      ((CompositeBuffer) bigBuffer).allowInternalBuffersDispose(true);
    }
    
    bigBuffer.dispose();
  }
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

@SuppressWarnings("unchecked")
protected void sendRaw(byte[] rawData) {
  final Connection connection = protocolHandler.getConnection();
  final MemoryManager mm = connection.getTransport().getMemoryManager();
  final Buffer buffer = Buffers.wrap(mm, rawData);
  buffer.allowBufferDispose(false);
  connection.write(buffer);
}

相关文章