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


##########
actor/src/main/scala/org/apache/pekko/util/Helpers.scala:
##########
@@ -195,4 +199,19 @@ object Helpers {
       Duration(config.getDuration(path, unit), unit)
   }
 
+  /**
+   * INTERNAL API
+   */
+  private[pekko] final implicit class FutureOps[T](val future: Future[T]) 
extends AnyVal {
+
+    /**
+     * Wait for the future to complete and return the result, or throw an 
exception if the future failed.
+     * Optimize for the case when the future is already completed.
+     * @since 1.2.0
+     */
+    def await(atMost: Duration = Duration.Inf): T = future.value match {
+      case Some(value) => value.get
+      case None        => blocking(future.result(atMost)(null))

Review Comment:
   avoid the double checking now



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to