Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2012 16:20
Show Gist options
  • Save anonymous/4286633 to your computer and use it in GitHub Desktop.
Save anonymous/4286633 to your computer and use it in GitHub Desktop.
autoCompilerPlugins := true,
libraryDependencies <+= scalaVersion {
v => compilerPlugin("org.scala-lang.plugins" % "continuations" % "2.10.0-RC5")
},
scalacOptions += "-P:continuations:enable",
"com.typesafe.akka" %% "akka-dataflow" % "2.1.0-RC5" cross CrossVersion.full // Substitute the Akka version number to the final once it's released
import scala.concurrent.ExecutionContext.Implicits.global // to have the default ExecutionContext in scope
import scala.concurrent.future
import akka.dataflow._ // to have access to flow + the conversions from Futures and Promises to dataflow constructs
val f1: Future[Long] = future { 1 * 5 }
val f2: Future[Long] = future { 3 * 5 }
flow { f1() + f2() } onComplete println // Will (asynchronously) print out the sum of the result of f1 and f2 once they are done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment