He-Pin commented on code in PR #628:
URL: https://github.com/apache/incubator-pekko/pull/628#discussion_r1315152410


##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala:
##########
@@ -1141,7 +1140,18 @@ trait FlowOps[+Out, +Mat] {
    *
    * @see [[#mapAsync]]
    */
-  def mapAsyncUnordered[T](parallelism: Int)(f: Out => Future[T]): Repr[T] = 
via(MapAsyncUnordered(parallelism, f))
+  def mapAsyncUnordered[T](parallelism: Int)(f: Out => Future[T]): Repr[T] =
+    unsafeTransformUnordered[T](parallelism) { (out, emitter) =>
+      val future = f(out)
+      future.value match {
+        case Some(elem) => 
emitter.asInstanceOf[UnsafeEmitter[T]].handleNow(elem)
+        case None       => 
future.onComplete(emitter.handle)(pekko.dispatch.ExecutionContexts.parasitic)
+      }
+    }

Review Comment:
   This change is a **demo** of how this method can be used.
   using `Emitter[T]` as context make code simpler in Scala but more forwarding.



-- 
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