Skip to content

Instantly share code, notes, and snippets.

@richdougherty
Forked from anonymous/gist:4286633
Created December 14, 2012 16:29
Show Gist options
  • Save richdougherty/4286699 to your computer and use it in GitHub Desktop.
Save richdougherty/4286699 to your computer and use it in GitHub Desktop.
autoCompilerPlugins := true,
libraryDependencies <+= scalaVersion {
v => compilerPlugin(
"org.scala-lang.plugins" %
"continuations" %
"2.10.0-RC5")
// Use the final Scala version once it's released
},
scalacOptions += "-P:continuations:enable",
"com.typesafe.akka" %% "akka-dataflow" %
"2.1.0-RC5" cross CrossVersion.full
// Use the final version of Akka 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