Would someone who has SBT installed help me out by running the
following instruction and reporting back what you see happen. Would be
good to get another opinion/data-point. Should take less than 5 mins:
mkdir akkatest
cd akkatest
<copy the following into build.sbt>
name := "DataflowConcurrencyExample"
version := "1.0"
scalaVersion := "2.9.2"
autoCompilerPlugins := true
resolvers += "Typesafe Repository" at
"http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.akka" % "akka-actor" % "2.0.1"
<end of build.sbt>
sbt
> console
scala> :paste
<paste the following into the terminal, then press ctl-D>
import akka.dispatch._
import Future.flow
object DataflowHelloWorld extends App {
implicit val dispatcher = akka.actor.ActorSystem().dispatcher
val x, y, z = Promise[Int]()
flow {
println("before z << x() + y()")
z << x() + y()
println("z = " + z())
}
flow {
println("before x << 40")
x << 40
println("x << 40")
}
flow {
println("before y << 2")
y << 2
println("y << 2")
}
}
<end of file>
scala> DataflowHelloWorld.main(Array())
<what do you see? does the program hang or terminate? please report back...>
See also: https://groups.google.com/forum/#!topic/akka-user/wHZBWRA5DOE
thanks
-Ben
scala> DataflowHelloWorld.main(Array())
before z << x() + y()
before x << 40
before y << 2
--
Tony Morris
http://tmorris.net/
Yay for 2.10 having continuations enabled by default so these kind of
problems don't happen any more.
What's a bit surprising to me is that the compiler plugin is needed to
compile the application code. I'd thought that it was only needed when
you compile the code with the @suspendable tag and continuations
instructions themselves. And since it was needed, why were there no
error or warnings during compile, just wrong execution logic?
-Ben
I think I remember someone requesting a "@requireCompilerPlugin" annotation on the list for this same reason, but I'm not sure what became of it.