Created
September 3, 2011 15:55
-
-
Save benmmurphy/1191381 to your computer and use it in GitHub Desktop.
Future
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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