diff options
author | Philipp Haller <hallerp@gmail.com> | 2013-06-25 02:11:16 +0200 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2013-06-25 02:55:26 +0200 |
commit | 6f6851c68659eae0d5d04ac9713413a3e592bd90 (patch) | |
tree | a9ab691f7bd43c74be21d5e64573b64b47d500af /src/test/scala/scala/async/TreeInterrogation.scala | |
parent | c13693ec9ab9905966f5768d7ad57bee33248c28 (diff) | |
download | scala-async-6f6851c68659eae0d5d04ac9713413a3e592bd90.tar.gz scala-async-6f6851c68659eae0d5d04ac9713413a3e592bd90.tar.bz2 scala-async-6f6851c68659eae0d5d04ac9713413a3e592bd90.zip |
Enable trampolining of async state execution
This replaces the previous body of an `async` block with a while
loop:
var task$async: Option[() => Unit] = Some(<future body>)
while (task$async.nonEmpty) {
val task = task$async.get
task$async = None
task()
}
This enables executing an `async` block on a single thread by using
a future system that blocks upon `await`. This execution mode can be
very useful for debugging. The introduced trampolining enables this
mode without running into stack overflows.
Diffstat (limited to 'src/test/scala/scala/async/TreeInterrogation.scala')
-rw-r--r-- | src/test/scala/scala/async/TreeInterrogation.scala | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/test/scala/scala/async/TreeInterrogation.scala b/src/test/scala/scala/async/TreeInterrogation.scala index deaee03..1eada08 100644 --- a/src/test/scala/scala/async/TreeInterrogation.scala +++ b/src/test/scala/scala/async/TreeInterrogation.scala @@ -35,13 +35,13 @@ class TreeInterrogation { case f: Function => f case t: Template => t } - functions.size mustBe 1 + functions.size mustBe 2 val varDefs = tree1.collect { case ValDef(mods, name, _, _) if mods.hasFlag(Flag.MUTABLE) => name } - varDefs.map(_.decoded.trim).toSet mustBe (Set("state$async", "await$1", "await$2")) - varDefs.map(_.decoded.trim).toSet mustBe (Set("state$async", "await$1", "await$2")) + varDefs.map(_.decoded.trim).toSet mustBe (Set("state$async", "await$1", "await$2", "task$async")) + varDefs.map(_.decoded.trim).toSet mustBe (Set("state$async", "await$1", "await$2", "task$async")) val defDefs = tree1.collect { case t: Template => |