diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-11-11 16:39:56 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-11-11 16:39:56 +0100 |
commit | 412682afb20def5e50533c300439828078d5e657 (patch) | |
tree | ac3f5e783dfe9ef98ed492147ca74d16f0eb92f3 | |
parent | ff74779ba949737b53cb3189dadf412815faf027 (diff) | |
download | scala-async-412682afb20def5e50533c300439828078d5e657.tar.gz scala-async-412682afb20def5e50533c300439828078d5e657.tar.bz2 scala-async-412682afb20def5e50533c300439828078d5e657.zip |
Use a var rather than a lazy val to break a cycle.
(onCompleteHandler and resume refer to each other)
-rw-r--r-- | src/main/scala/scala/async/Async.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main/scala/scala/async/Async.scala b/src/main/scala/scala/async/Async.scala index c6b7c19..16bca6b 100644 --- a/src/main/scala/scala/async/Async.scala +++ b/src/main/scala/scala/async/Async.scala @@ -98,10 +98,9 @@ abstract class AsyncBase { */ val onCompleteHandler = { val onCompleteHandlers = initStates.flatMap(_.mkOnCompleteHandler).toList - ValDef(Modifiers(LAZY), name.onCompleteHandler, TypeTree(), Function( List(ValDef(Modifiers(PARAM), name.tr, TypeTree(TryAnyType), EmptyTree)), - Match(Ident(name.state), onCompleteHandlers))) + Match(Ident(name.state), onCompleteHandlers)) } /* @@ -139,6 +138,7 @@ abstract class AsyncBase { var state$async = 0 // Resolve the execution context var execContext$async = futureSystemOps.execContext.splice + var onCompleteHandler$async: util.Try[Any] => Unit = null // Spawn a future to: futureSystemOps.future[Unit] { @@ -147,8 +147,8 @@ abstract class AsyncBase { localVarTrees :+ // define the resume() method resumeFunTree :+ - // define the onComplete function - onCompleteHandler, + // assign onComplete function. (The var breaks the circular dependency with resume)` + Assign(Ident(name.onCompleteHandler), onCompleteHandler), // and get things started by calling resume() Apply(Ident(name.resume), Nil))) }(c.Expr[futureSystem.ExecContext](Ident(name.execContext))).splice |