Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>import akka.dataflow._ import scala.concurrent._, ExecutionContext.Implicits._ // the following are for duration import scala.language.postfixOps import scala.concurrent.duration._ object FlowTestApp extends App { val f = flow { println("in flow") "Hello world!" } onComplete println Await.ready(f, 1 second) } </code></pre> <p>If you're thinking about using Akka Dataflow as a non-blocking alternative to threads, here's my 2 cents:</p> <p>Some core language features (e.g. loops, try/finally) break in the delimited code blocks. I've been using it for some I/O and I'm happy with it, but I'd make sure to keep it under the hood.</p> <p>%99 of akka-dataflow is Scala's continuations plugin. The definition of <a href="https://github.com/akka/akka/blob/master/akka-dataflow/src/main/scala/akka/dataflow/package.scala#L31" rel="nofollow">flow()</a> (which boggles my mind) and the pimped Future#apply() are really all that's needed, and they're quite small. Scala's continuations plugin, however, is much more generic than the problem of non-blocking threads.</p> <p>For an alternative solution, keep track of <a href="https://github.com/scala/async" rel="nofollow">scala-async</a>, which has a much more specific approach (transforming your seemingly sequential code into <code>future { ... } flatMap { ... }</code> blocks)</p> <p>I tried it last week, and as of that time scala-async's code transformation still covered less than what is supported by akka-dataflow, but from looking at the commit log it seems to be gaining fast and will soon surpass it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload