io.netty.channel.Channel.unsafe()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(168)

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

Channel.unsafe介绍

[英]Returns an internal-use-only object that provides unsafe operations.
[中]返回提供不安全操作的仅限内部使用对象。

代码示例

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

@Deprecated
@Override
public ChannelFuture register(Channel channel, ChannelPromise promise) {
  channel.unsafe().register(this, promise);
  return promise;
}

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

@Deprecated
@Override
public ChannelFuture register(final Channel channel, final ChannelPromise promise) {
  if (channel == null) {
    throw new NullPointerException("channel");
  }
  if (promise == null) {
    throw new NullPointerException("promise");
  }
  channel.unsafe().register(this, promise);
  return promise;
}

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

@Deprecated
@Override
public ChannelFuture register(Channel channel, ChannelPromise promise) {
  channel.unsafe().register(this, promise);
  return promise;
}

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

@Deprecated
@Override
public ChannelFuture register(final Channel channel, final ChannelPromise promise) {
  if (channel == null) {
    throw new NullPointerException("channel");
  }
  if (promise == null) {
    throw new NullPointerException("promise");
  }
  channel.unsafe().register(this, promise);
  return promise;
}

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

HeadContext(DefaultChannelPipeline pipeline) {
  super(pipeline, null, HEAD_NAME, true, true);
  unsafe = pipeline.channel().unsafe();
  setAddComplete();
}

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

private static void forceClose(Channel child, Throwable t) {
  child.unsafe().closeForcibly();
  logger.warn("Failed to register an accepted channel: {}", child, t);
}

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

void setUserDefinedWritability(ChannelHandlerContext ctx, boolean writable) {
  ChannelOutboundBuffer cob = ctx.channel().unsafe().outboundBuffer();
  if (cob != null) {
    cob.setUserDefinedWritability(userDefinedWritabilityIndex, writable);
  }
}

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

HeadContext(DefaultChannelPipeline pipeline) {
  super(pipeline, null, HEAD_NAME, true, true);
  unsafe = pipeline.channel().unsafe();
  setAddComplete();
}

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

private static void forceClose(Channel child, Throwable t) {
  child.unsafe().closeForcibly();
  logger.warn("Failed to register an accepted channel: {}", child, t);
}

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

/**
 * @see #hasOutputChanged(ChannelHandlerContext, boolean)
 */
private void initOutputChanged(ChannelHandlerContext ctx) {
  if (observeOutput) {
    Channel channel = ctx.channel();
    Unsafe unsafe = channel.unsafe();
    ChannelOutboundBuffer buf = unsafe.outboundBuffer();
    if (buf != null) {
      lastMessageHashCode = System.identityHashCode(buf.current());
      lastPendingWriteBytes = buf.totalPendingWriteBytes();
    }
  }
}

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

@Override
public ChannelFuture register(ChannelPromise promise) {
  ObjectUtil.checkNotNull(promise, "promise");
  promise.channel().unsafe().register(this, promise);
  return promise;
}

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

@UnstableApi
protected void incrementPendingOutboundBytes(long size) {
  ChannelOutboundBuffer buffer = channel.unsafe().outboundBuffer();
  if (buffer != null) {
    buffer.incrementPendingOutboundBytes(size);
  }
}

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

@UnstableApi
protected void decrementPendingOutboundBytes(long size) {
  ChannelOutboundBuffer buffer = channel.unsafe().outboundBuffer();
  if (buffer != null) {
    buffer.decrementPendingOutboundBytes(size);
  }
}

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

@Override
public ChannelFuture register(final ChannelPromise promise) {
  ObjectUtil.checkNotNull(promise, "promise");
  promise.channel().unsafe().register(this, promise);
  return promise;
}

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

@UnstableApi
protected void incrementPendingOutboundBytes(long size) {
  ChannelOutboundBuffer buffer = channel.unsafe().outboundBuffer();
  if (buffer != null) {
    buffer.incrementPendingOutboundBytes(size);
  }
}

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

@UnstableApi
protected void decrementPendingOutboundBytes(long size) {
  ChannelOutboundBuffer buffer = channel.unsafe().outboundBuffer();
  if (buffer != null) {
    buffer.decrementPendingOutboundBytes(size);
  }
}

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

@Override
public ChannelFuture register(final ChannelPromise promise) {
  ObjectUtil.checkNotNull(promise, "promise");
  promise.channel().unsafe().register(this, promise);
  return promise;
}

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

@Override
public ChannelFuture register(ChannelPromise promise) {
  ObjectUtil.checkNotNull(promise, "promise");
  promise.channel().unsafe().register(this, promise);
  return promise;
}

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

static PendingBytesTracker newTracker(Channel channel) {
  if (channel.pipeline() instanceof DefaultChannelPipeline) {
    return new DefaultChannelPipelinePendingBytesTracker((DefaultChannelPipeline) channel.pipeline());
  } else {
    ChannelOutboundBuffer buffer = channel.unsafe().outboundBuffer();
    MessageSizeEstimator.Handle handle = channel.config().getMessageSizeEstimator().newHandle();
    // We need to guard against null as channel.unsafe().outboundBuffer() may returned null
    // if the channel was already closed when constructing the PendingBytesTracker.
    // See https://github.com/netty/netty/issues/3967
    return buffer == null ?
        new NoopPendingBytesTracker(handle) : new ChannelOutboundBufferPendingBytesTracker(buffer, handle);
  }
}

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

static PendingBytesTracker newTracker(Channel channel) {
  if (channel.pipeline() instanceof DefaultChannelPipeline) {
    return new DefaultChannelPipelinePendingBytesTracker((DefaultChannelPipeline) channel.pipeline());
  } else {
    ChannelOutboundBuffer buffer = channel.unsafe().outboundBuffer();
    MessageSizeEstimator.Handle handle = channel.config().getMessageSizeEstimator().newHandle();
    // We need to guard against null as channel.unsafe().outboundBuffer() may returned null
    // if the channel was already closed when constructing the PendingBytesTracker.
    // See https://github.com/netty/netty/issues/3967
    return buffer == null ?
        new NoopPendingBytesTracker(handle) : new ChannelOutboundBufferPendingBytesTracker(buffer, handle);
  }
}

相关文章