有没有理由弃用关机方法?

ste*_*lla 9 akka

在关闭ActorSystem的时候,我发现它ActorSystem::shutdown已被弃用了.这是建议的"Use the terminate() method instead".

但这些方法的解释几乎相同:

  /**
   * Terminates this actor system. This will stop the guardian actor, which in turn
   * will recursively stop all its child actors, then the system guardian
   * (below which the logging actors reside) and the execute all registered
   * termination handlers (see [[ActorSystem#registerOnTermination]]).
   * Be careful to not schedule any operations on completion of the returned future
   * using the `dispatcher` of this actor system as it will have been shut down before the
   * future completes.
   */
  def terminate(): Future[Terminated]
Run Code Online (Sandbox Code Playgroud)

  /**
   * Stop this actor system. This will stop the guardian actor, which in turn
   * will recursively stop all its child actors, then the system guardian
   * (below which the logging actors reside) and the execute all registered
   * termination handlers (see [[ActorSystem#registerOnTermination]]).
   */
  @deprecated("Use the terminate() method instead", "2.4")
  def shutdown(): Unit
Run Code Online (Sandbox Code Playgroud)

但有一个例外,即返回类型已更改.弃用的原因是shutdown什么?不安全吗?

bla*_*ide 8

似乎弃用是遵循项目其他领域中使用的"终止"约定,以及暴露终止事件.

重要的部分是终止事件:

终止挂钩允许系统参与者在系统关闭或重新启动之前执行最终清理 - 在这种特殊情况下,让远程系统知道关闭系统上的任何远程部署的actor已经死亡,但是在其他情况下在Akka核心内部使用

有关更多信息,请参阅以下内容