org.xnio.IoUtils.safeShutdownReads()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(115)

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

IoUtils.safeShutdownReads介绍

[英]Safely shutdown reads on the given channel.
[中]安全关闭给定通道上的读取。

代码示例

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

public void handleEvent(final T channel) {
  try {
    long count = this.count;
    try {
      long res;
      for (;;) {
        res = Channels.drain(channel, count);
        if (res == -1 || res == count) {
          this.count = 0L;
          invokeChannelListener(channel, finishListener);
          return;
        } else if (res == 0) {
          return;
        } else if (count < Long.MAX_VALUE) {
          // MAX_VALUE means drain to EOF
          count -= res;
        }
      }
    } finally {
      this.count = count;
    }
  } catch (IOException e) {
    this.count = 0L;
    if (exceptionHandler != null) {
      invokeChannelExceptionHandler(channel, exceptionHandler, e);
    } else {
      IoUtils.safeShutdownReads(channel);
    }
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public void handleEvent(final T channel) {
  try {
    long count = this.count;
    try {
      long res;
      for (;;) {
        res = Channels.drain(channel, count);
        if (res == -1 || res == count) {
          this.count = 0L;
          invokeChannelListener(channel, finishListener);
          return;
        } else if (res == 0) {
          return;
        } else if (count < Long.MAX_VALUE) {
          // MAX_VALUE means drain to EOF
          count -= res;
        }
      }
    } finally {
      this.count = count;
    }
  } catch (IOException e) {
    this.count = 0L;
    if (exceptionHandler != null) {
      invokeChannelExceptionHandler(channel, exceptionHandler, e);
    } else {
      IoUtils.safeShutdownReads(channel);
    }
  }
}

代码示例来源:origin: org.jboss.remoting3/jboss-remoting

protected void closeAction() throws IOException {
  sendCloseRequest();
  IoUtils.safeShutdownReads(remoteConnection.getChannel());
  remoteConnection.shutdownWrites();
  // now these guys can't send useless messages
  closePendingChannels();
  closeAllChannels();
  remoteConnection.getRemoteConnectionProvider().removeConnectionHandler(this);
}

相关文章