diff options
author | Philipp Haller <hallerp@gmail.com> | 2007-11-29 18:51:31 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2007-11-29 18:51:31 +0000 |
commit | 0d95261bbcd4429b115608e1afe6648b844d92dc (patch) | |
tree | 15e2b8795c49807e0e4e4e6df686ce43c9f45661 /src | |
parent | 5e175852a78b2ca4b8b42e1d0cc79c2bd5b72a0f (diff) | |
download | scala-0d95261bbcd4429b115608e1afe6648b844d92dc.tar.gz scala-0d95261bbcd4429b115608e1afe6648b844d92dc.tar.bz2 scala-0d95261bbcd4429b115608e1afe6648b844d92dc.zip |
Fixed issue that avoids evaluating expressions ...
Fixed issue that avoids evaluating expressions after andThen and
continue.
Diffstat (limited to 'src')
-rw-r--r-- | src/actors/scala/actors/Actor.scala | 6 | ||||
-rw-r--r-- | src/actors/scala/actors/Reaction.scala | 32 |
2 files changed, 29 insertions, 9 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala index beae0652a5..5bde8948ca 100644 --- a/src/actors/scala/actors/Actor.scala +++ b/src/actors/scala/actors/Actor.scala @@ -205,6 +205,7 @@ object Actor { */ def loopWhile(cond: => Boolean)(body: => Unit): Unit = if (cond) { body andThen loopWhile(cond)(body) } + else continue /** * Links <code>self</code> to actor <code>to</code>. @@ -261,7 +262,7 @@ object Actor { */ def exit(): Nothing = self.exit() - def continue: Unit = self.kill() + def continue: Unit = throw new KillActorException } /** @@ -612,7 +613,7 @@ trait Actor extends OutputChannel[Any] { private var isWaiting = false // guarded by lock of this - private def scheduleActor(f: PartialFunction[Any, Unit], msg: Any) = + protected def scheduleActor(f: PartialFunction[Any, Unit], msg: Any) = if ((f eq null) && (continuation eq null)) { // do nothing (timeout is handled instead) } @@ -697,6 +698,7 @@ trait Actor extends OutputChannel[Any] { throw new SuspendActorException } first + throw new KillActorException } private[actors] var links: List[Actor] = Nil diff --git a/src/actors/scala/actors/Reaction.scala b/src/actors/scala/actors/Reaction.scala index 1e8321e351..8807efa074 100644 --- a/src/actors/scala/actors/Reaction.scala +++ b/src/actors/scala/actors/Reaction.scala @@ -19,10 +19,24 @@ import java.lang.{InterruptedException, Runnable} * return type <code>Nothing</code>. * </p> * - * @version 0.9.8 + * @version 0.9.10 * @author Philipp Haller */ -private[actors] class ExitActorException extends Throwable +private[actors] class ExitActorException extends Throwable { + /* + * For efficiency reasons we do not fill in + * the execution stack trace. + */ + override def fillInStackTrace(): Throwable = this +} + +private[actors] class KillActorException extends Throwable { + /* + * For efficiency reasons we do not fill in + * the execution stack trace. + */ + override def fillInStackTrace(): Throwable = this +} /** <p> * The abstract class <code>Reaction</code> associates @@ -31,7 +45,7 @@ private[actors] class ExitActorException extends Throwable * <code>java.lang.Runnable</code></a>. * </p> * - * @version 0.9.8 + * @version 0.9.10 * @author Philipp Haller */ /*private[actors]*/ class Reaction(a: Actor, @@ -47,10 +61,14 @@ private[actors] class ExitActorException extends Throwable if (a.shouldExit) // links a.exit() else { - if (f == null) - a.act() - else - f(msg) + try { + if (f == null) + a.act() + else + f(msg) + } catch { + case _: KillActorException => + } a.kill(); a.exit() } } |