diff --git a/akka-dataflow/src/main/scala/akka/dataflow/package.scala b/akka-dataflow/src/main/scala/akka/dataflow/package.scala index 9f4e6a0da2..31248958d1 100644 --- a/akka-dataflow/src/main/scala/akka/dataflow/package.scala +++ b/akka-dataflow/src/main/scala/akka/dataflow/package.scala @@ -46,7 +46,7 @@ package object dataflow { implicit class DataflowPromise[T](val promise: Promise[T]) extends AnyVal { /** - * Completes the Promise with the speicifed value or throws an exception if already + * Completes the Promise with the specified value or throws an exception if already * completed. See Promise.success(value) for semantics. * * @param value The value which denotes the successful value of the Promise @@ -59,7 +59,7 @@ package object dataflow { /** * Completes this Promise with the value of the specified Future when/if it completes. * - * @param other The Future whose value will be transfered to this Promise upon completion + * @param other The Future whose value will be transferred to this Promise upon completion * @param ec An ExecutionContext which will be used to execute callbacks registered in this method * @return A Future representing the result of this operation */ @@ -75,7 +75,7 @@ package object dataflow { /** * Completes this Promise with the value of the specified Promise when/if it completes. * - * @param other The Promise whose value will be transfered to this Promise upon completion + * @param other The Promise whose value will be transferred to this Promise upon completion * @param ec An ExecutionContext which will be used to execute callbacks registered in this method * @return A Future representing the result of this operation */ diff --git a/akka-docs/rst/scala/code/docs/dataflow/DataflowDocSpec.scala b/akka-docs/rst/scala/code/docs/dataflow/DataflowDocSpec.scala index a32ee6fcae..345d23b4ac 100644 --- a/akka-docs/rst/scala/code/docs/dataflow/DataflowDocSpec.scala +++ b/akka-docs/rst/scala/code/docs/dataflow/DataflowDocSpec.scala @@ -44,21 +44,23 @@ class DataflowDocSpec extends WordSpec with MustMatchers { } "demonstrate the use of dataflow variables" in { - def println[T](any: Try[T]): Unit = any.get must be === 20 + val result = Promise[Int]() + def println(any: Try[Int]): Unit = result.complete(any) //#dataflow-variable-a + val v1, v2 = Promise[Int]() flow { - val v1, v2 = Promise[Int]() - // v1 will become the value of v2 + 10 when v2 gets a value v1 << v2() + 10 - v2 << flow { 5 } // As you can see, no blocking! v1() + v2() } onComplete println + flow { v2 << 5 } // As you can see, no blocking above! //#dataflow-variable-a + Await.result(result.future, 10.seconds) must be === 20 } "demonstrate the difference between for and flow" in { - def println[T](any: Try[T]): Unit = any.get must be === 2 + val result = Promise[Int]() + def println(any: Try[Int]): Unit = result.tryComplete(any) //#for-vs-flow val f1, f2 = Future { 1 } @@ -68,6 +70,7 @@ class DataflowDocSpec extends WordSpec with MustMatchers { usingFor onComplete println usingFlow onComplete println //#for-vs-flow + Await.result(result.future, 10.seconds) must be === 2 } }