コード例 #1
0
ファイル: HttpClientFactory.java プロジェクト: hdpter/rest.li
  private void finishShutdown() {
    if (!_finishingShutdown.compareAndSet(false, true)) {
      return;
    }
    if (_shutdownTimeoutTask != null) {
      _shutdownTimeoutTask.cancel(false);
    }

    if (_shutdownFactory) {
      LOG.info("Shutdown Netty Event Loop");
      _eventLoopGroup.shutdownGracefully(0, 0, TimeUnit.SECONDS);
    }

    if (_shutdownExecutor) {
      // Due to a bug in ScheduledThreadPoolExecutor, shutdownNow() returns cancelled
      // tasks as though they were still pending execution.  If the executor has a large
      // number of cancelled tasks, shutdownNow() could take a long time to copy the array
      // of tasks.  Calling shutdown() first will purge the cancelled tasks.  Bug filed with
      // Oracle; will provide bug number when available.  May be fixed in JDK7 already.
      _executor.shutdown();
      _executor.shutdownNow();
      LOG.info("Scheduler shutdown complete");
    }

    if (_shutdownCallbackExecutor) {
      LOG.info("Shutdown callback executor");
      _callbackExecutorGroup.shutdown();
      _callbackExecutorGroup.shutdownNow();
    }

    final Callback<None> callback;
    synchronized (_mutex) {
      callback = _factoryShutdownCallback;
    }

    LOG.info("Shutdown complete");
    callback.onSuccess(None.none());
  }
コード例 #2
0
 @Override
 public void start(Callback<None> callback) {
   callback.onSuccess(None.none());
 }