Exemplo n.º 1
0
  /** Closes the inbox */
  @Override
  public void shutdown(ShutdownModeAmp mode) {
    if (!_lifecycle.toStopping()) {
      return;
    }

    _lifecycle.toDestroy();

    OnShutdownMessage shutdownMessage = new OnShutdownMessage(this, mode, isSingle());

    _queue.offer(shutdownMessage);

    // _queue.close();
    /*
    for (Actor<?> actorProcessor : _queueActors) {
      actorProcessor.close();
    }
    */

    _queue.wakeAllAndWait();

    shutdownMessage.waitFor(1, TimeUnit.SECONDS);

    super.shutdown(mode);

    try (OutboxAmp outbox = OutboxAmp.currentOrCreate(manager())) {
      Object ctx = outbox.getAndSetContext(this);

      try {
        outbox.flush();

        if (!isSingle()) {
          _worker.shutdown(mode);
        }
      } finally {
        outbox.getAndSetContext(ctx);
      }
    }

    // XXX: _worker.shutdown(ShutdownModeAmp.IMMEDIATE);
  }
Exemplo n.º 2
0
 public void wakeAllAndWait() {
   _queue.wakeAllAndWait();
 }