He-Pin commented on code in PR #2096:
URL: https://github.com/apache/pekko/pull/2096#discussion_r2299707074


##########
actor-typed/src/main/scala/org/apache/pekko/actor/typed/ActorSystem.scala:
##########
@@ -125,6 +127,33 @@ abstract class ActorSystem[-T] extends ActorRef[T] with 
Extensions with ClassicA
    */
   def terminate(): Unit
 
+  /**
+   * Terminates this actor system and blocks the current thread until it is 
terminated,
+   * waiting at most the given duration.
+   *
+   * @param atMost the maximum duration to wait
+   * @throws java.util.concurrent.TimeoutException if the wait timed out
+   * @throws InterruptedException if the current thread is interrupted while 
waiting
+   */
+  def terminateAndAwait(atMost: Duration): Unit = {
+    import scala.concurrent.Await
+    Await.result(whenTerminated, atMost)
+  }
+
+  /**
+   * Terminates this actor system and blocks the current thread until it is 
terminated,
+   * waiting at most the given duration.
+   *
+   * @param atMost the maximum duration to wait
+   * @throws java.util.concurrent.TimeoutException if the wait timed out
+   * @throws InterruptedException if the current thread is interrupted while 
waiting
+   */
+  def terminateAndAwait(atMost: java.time.Duration): Unit = {
+    import scala.concurrent.Await
+    import pekko.util.JavaDurationConverters._
+    Await.result(whenTerminated, atMost.asScala)
+  }

Review Comment:
   Added these two methods



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org
For additional commands, e-mail: notifications-h...@pekko.apache.org

Reply via email to