diff options
Diffstat (limited to 'src/actors')
-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() } } |