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

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

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

IoUtils.directExecutor介绍

[英]Get the direct executor. This is an executor that executes the provided task in the same thread.
[中]找直接执行人。这是在同一线程中执行所提供任务的执行器。

代码示例

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

/**
 * Construct a new instance.  The direct executor will be used to execute handler notifiers.
 */
public FutureResult() {
  this(IoUtils.directExecutor());
}

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

/**
 * Get the executor used to run asynchronous notifiers.  By default, this implementation simply returns the direct
 * executor.
 *
 * @return the executor to use
 */
protected Executor getNotifierExecutor() {
  return IoUtils.directExecutor();
}

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

@SuppressWarnings("deprecation")
public IoFuture<ConnectedSslStreamChannel> connectSsl(final XnioWorker worker, final InetSocketAddress bindAddress, final InetSocketAddress destination, final ChannelListener<? super ConnectedSslStreamChannel> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap) {
  final FutureResult<ConnectedSslStreamChannel> futureResult = new FutureResult<ConnectedSslStreamChannel>(IoUtils.directExecutor());
  final IoFuture<SslConnection> futureSslConnection = openSslConnection(worker, bindAddress, destination, new ChannelListener<SslConnection>() {
        public void handleEvent(final SslConnection sslConnection) {
          final ConnectedSslStreamChannel assembledChannel = new AssembledConnectedSslStreamChannel(sslConnection, sslConnection.getSourceChannel(), sslConnection.getSinkChannel());
          if (!futureResult.setResult(assembledChannel)) {
            safeClose(assembledChannel);
          } else {
            ChannelListeners.invokeChannelListener(assembledChannel, openListener);
          }
        }
      }, bindListener, optionMap).addNotifier(new IoFuture.HandlingNotifier<SslConnection, FutureResult<ConnectedSslStreamChannel>>() {
    public void handleCancelled(final FutureResult<ConnectedSslStreamChannel> result) {
      result.setCancelled();
    }
    public void handleFailed(final IOException exception, final FutureResult<ConnectedSslStreamChannel> result) {
      result.setException(exception);
    }
  }, futureResult);
  futureResult.getIoFuture().addNotifier(new IoFuture.HandlingNotifier<ConnectedStreamChannel, IoFuture<SslConnection>>() {
    public void handleCancelled(final IoFuture<SslConnection> result) {
      result.cancel();
    }
  }, futureSslConnection);
  futureResult.addCancelHandler(futureSslConnection);
  return futureResult.getIoFuture();
}

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

@SuppressWarnings("deprecation")
public IoFuture<ConnectedSslStreamChannel> connectSsl(final XnioWorker worker, final InetSocketAddress bindAddress, final InetSocketAddress destination, final ChannelListener<? super ConnectedSslStreamChannel> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap) {
  final FutureResult<ConnectedSslStreamChannel> futureResult = new FutureResult<>(IoUtils.directExecutor());
  final IoFuture<SslConnection> futureSslConnection = openSslConnection(worker, bindAddress, destination, new ChannelListener<SslConnection>() {
    public void handleEvent(final SslConnection sslConnection) {
      final ConnectedSslStreamChannel assembledChannel = new AssembledConnectedSslStreamChannel(sslConnection, sslConnection.getSourceChannel(), sslConnection.getSinkChannel());
      if (!futureResult.setResult(assembledChannel)) {
        safeClose(assembledChannel);
      } else {
        ChannelListeners.invokeChannelListener(assembledChannel, openListener);
      }
    }
  }, bindListener, optionMap).addNotifier(new IoFuture.HandlingNotifier<SslConnection, FutureResult<ConnectedSslStreamChannel>>() {
    public void handleCancelled(final FutureResult<ConnectedSslStreamChannel> result) {
      result.setCancelled();
    }
    public void handleFailed(final IOException exception, final FutureResult<ConnectedSslStreamChannel> result) {
      result.setException(exception);
    }
  }, futureResult);
  futureResult.getIoFuture().addNotifier(new IoFuture.HandlingNotifier<ConnectedStreamChannel, IoFuture<SslConnection>>() {
    public void handleCancelled(final IoFuture<SslConnection> result) {
      result.cancel();
    }
  }, futureSslConnection);
  futureResult.addCancelHandler(futureSslConnection);
  return futureResult.getIoFuture();
}

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

/**
 * Get the executor used to run asynchronous notifiers.  By default, this implementation simply returns the direct
 * executor.
 *
 * @return the executor to use
 */
protected Executor getNotifierExecutor() {
  return IoUtils.directExecutor();
}

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

/**
 * Construct a new instance.  The direct executor will be used to execute handler notifiers.
 */
public FutureResult() {
  this(IoUtils.directExecutor());
}

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

@SuppressWarnings("deprecation")
public IoFuture<ConnectedSslStreamChannel> connectSsl(final XnioWorker worker, final InetSocketAddress bindAddress, final InetSocketAddress destination, final ChannelListener<? super ConnectedSslStreamChannel> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap) {
  final FutureResult<ConnectedSslStreamChannel> futureResult = new FutureResult<>(IoUtils.directExecutor());
  final IoFuture<SslConnection> futureSslConnection = openSslConnection(worker, bindAddress, destination, new ChannelListener<SslConnection>() {
    public void handleEvent(final SslConnection sslConnection) {
      final ConnectedSslStreamChannel assembledChannel = new AssembledConnectedSslStreamChannel(sslConnection, sslConnection.getSourceChannel(), sslConnection.getSinkChannel());
      if (!futureResult.setResult(assembledChannel)) {
        safeClose(assembledChannel);
      } else {
        ChannelListeners.invokeChannelListener(assembledChannel, openListener);
      }
    }
  }, bindListener, optionMap).addNotifier(new IoFuture.HandlingNotifier<SslConnection, FutureResult<ConnectedSslStreamChannel>>() {
    public void handleCancelled(final FutureResult<ConnectedSslStreamChannel> result) {
      result.setCancelled();
    }
    public void handleFailed(final IOException exception, final FutureResult<ConnectedSslStreamChannel> result) {
      result.setException(exception);
    }
  }, futureResult);
  futureResult.getIoFuture().addNotifier(new IoFuture.HandlingNotifier<ConnectedStreamChannel, IoFuture<SslConnection>>() {
    public void handleCancelled(final IoFuture<SslConnection> result) {
      result.cancel();
    }
  }, futureSslConnection);
  futureResult.addCancelHandler(futureSslConnection);
  return futureResult.getIoFuture();
}

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

@SuppressWarnings("deprecation")
public IoFuture<ConnectedSslStreamChannel> connectSsl(final XnioWorker worker, final InetSocketAddress bindAddress, final InetSocketAddress destination, final ChannelListener<? super ConnectedSslStreamChannel> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap) {
  final FutureResult<ConnectedSslStreamChannel> futureResult = new FutureResult<ConnectedSslStreamChannel>(IoUtils.directExecutor());
  final IoFuture<SslConnection> futureSslConnection = openSslConnection(worker, bindAddress, destination, new ChannelListener<SslConnection>() {
        public void handleEvent(final SslConnection sslConnection) {
          final ConnectedSslStreamChannel assembledChannel = new AssembledConnectedSslStreamChannel(sslConnection, sslConnection.getSourceChannel(), sslConnection.getSinkChannel());
          if (!futureResult.setResult(assembledChannel)) {
            safeClose(assembledChannel);
          } else {
            ChannelListeners.invokeChannelListener(assembledChannel, openListener);
          }
        }
      }, bindListener, optionMap).addNotifier(new IoFuture.HandlingNotifier<SslConnection, FutureResult<ConnectedSslStreamChannel>>() {
    public void handleCancelled(final FutureResult<ConnectedSslStreamChannel> result) {
      result.setCancelled();
    }
    public void handleFailed(final IOException exception, final FutureResult<ConnectedSslStreamChannel> result) {
      result.setException(exception);
    }
  }, futureResult);
  futureResult.getIoFuture().addNotifier(new IoFuture.HandlingNotifier<ConnectedStreamChannel, IoFuture<SslConnection>>() {
    public void handleCancelled(final IoFuture<SslConnection> result) {
      result.cancel();
    }
  }, futureSslConnection);
  futureResult.addCancelHandler(futureSslConnection);
  return futureResult.getIoFuture();
}

代码示例来源:origin: io.undertow/undertow-core

@SuppressWarnings("deprecation")
public IoFuture<ConnectedSslStreamChannel> connectSsl(final XnioWorker worker, final InetSocketAddress bindAddress, final InetSocketAddress destination, final ChannelListener<? super ConnectedSslStreamChannel> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap) {
  final FutureResult<ConnectedSslStreamChannel> futureResult = new FutureResult<>(IoUtils.directExecutor());
  final IoFuture<SslConnection> futureSslConnection = openSslConnection(worker, bindAddress, destination, new ChannelListener<SslConnection>() {
    public void handleEvent(final SslConnection sslConnection) {
      final ConnectedSslStreamChannel assembledChannel = new AssembledConnectedSslStreamChannel(sslConnection, sslConnection.getSourceChannel(), sslConnection.getSinkChannel());
      if (!futureResult.setResult(assembledChannel)) {
        safeClose(assembledChannel);
      } else {
        ChannelListeners.invokeChannelListener(assembledChannel, openListener);
      }
    }
  }, bindListener, optionMap).addNotifier(new IoFuture.HandlingNotifier<SslConnection, FutureResult<ConnectedSslStreamChannel>>() {
    public void handleCancelled(final FutureResult<ConnectedSslStreamChannel> result) {
      result.setCancelled();
    }
    public void handleFailed(final IOException exception, final FutureResult<ConnectedSslStreamChannel> result) {
      result.setException(exception);
    }
  }, futureResult);
  futureResult.getIoFuture().addNotifier(new IoFuture.HandlingNotifier<ConnectedStreamChannel, IoFuture<SslConnection>>() {
    public void handleCancelled(final IoFuture<SslConnection> result) {
      result.cancel();
    }
  }, futureSslConnection);
  futureResult.addCancelHandler(futureSslConnection);
  return futureResult.getIoFuture();
}

相关文章