Skip to content

Instantly share code, notes, and snippets.

@benmmurphy
Created September 3, 2011 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benmmurphy/1191381 to your computer and use it in GitHub Desktop.
Save benmmurphy/1191381 to your computer and use it in GitHub Desktop.
Future
import scala.util.continuations._
import scala.collection.mutable._
class Future {
def await : Unit @suspendable = {
/* .... */
shift { k : (Unit => Unit) =>
}
}
}
object Future {
def sleep(delay:Int) : Unit @suspendable = {
shift { k : (Unit => Unit) =>
/* ... */
}
}
def future(targetFunc: (Int => Unit @suspendable)) : (Int => Future) = {
/* ... */
null
}
def main(args:Array[String]) = {
reset {
val sleepAsync = future(sleep)
val future1 = sleepAsync(2000)
val future2 = sleepAsync(3000)
future1.await
future2.await
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment