From 033463f87fe71e8f6d5b17f7cb82b8c2ea5f5271 Mon Sep 17 00:00:00 2001 From: Vojin Jovanovic Date: Wed, 23 May 2012 09:46:21 +0200 Subject: Minor fixes for the Actor Migration Kit Fixed behavior of the StashingActor in case of unhandeled message. Fixed a typo in deprecated annotation. Fixed comments. Fixed copyright. --- src/actors-migration/scala/actors/Props.scala | 3 +-- .../scala/actors/StashingActor.scala | 22 ++++++++-------------- src/actors-migration/scala/actors/Timeout.scala | 11 ++++++++--- src/actors/scala/actors/ReplyReactor.scala | 7 ++----- 4 files changed, 19 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/actors-migration/scala/actors/Props.scala b/src/actors-migration/scala/actors/Props.scala index b4d18d5fad..891e23213a 100644 --- a/src/actors-migration/scala/actors/Props.scala +++ b/src/actors-migration/scala/actors/Props.scala @@ -7,8 +7,7 @@ case class Props(creator: () ⇒ InternalActor, dispatcher: String) { /** * Returns a new Props with the specified creator set - * Scala API */ def withCreator(c: ⇒ InternalActor) = copy(creator = () ⇒ c) -} \ No newline at end of file +} diff --git a/src/actors-migration/scala/actors/StashingActor.scala b/src/actors-migration/scala/actors/StashingActor.scala index 4bca879d9f..37300f9d63 100644 --- a/src/actors-migration/scala/actors/StashingActor.scala +++ b/src/actors-migration/scala/actors/StashingActor.scala @@ -10,7 +10,7 @@ object StashingActor extends Combinators { } } -@deprecated("Scala Actors are beeing removed from the standard library. Please refer to the migration guide.", "2.10") +@deprecated("Scala Actors are being removed from the standard library. Please refer to the migration guide.", "2.10") trait StashingActor extends InternalActor { type Receive = PartialFunction[Any, Unit] @@ -83,9 +83,9 @@ trait StashingActor extends InternalActor { * by default it does: EventHandler.warning(self, message) */ def unhandled(message: Any) { - println("unhandeld") message match { - case _ => throw new UnhandledMessageException(message, self) + case Terminated(dead) ⇒ throw new DeathPactException(dead) + case _ ⇒ System.err.println("Unhandeled message " + message) } } @@ -152,7 +152,6 @@ trait StashingActor extends InternalActor { def swapExitHandler(pf: PartialFunction[Any, Unit]) = new PartialFunction[Any, Unit] { def swapExit(v: Any) = v match { case Exit(from, reason) => - Terminated(new InternalActorRef(from.asInstanceOf[InternalActor])) case v => v } @@ -244,18 +243,13 @@ trait StashingActor extends InternalActor { } /** - * This message is thrown by default when an Actors behavior doesn't match a message + * This message is thrown by default when an Actor does not handle termination. */ -case class UnhandledMessageException(msg: Any, ref: ActorRef = null) extends Exception { - - def this(msg: String) = this(msg, null) - - // constructor with 'null' ActorRef needed to work with client instantiation of remote exception - override def getMessage = - if (ref ne null) "Actor %s does not handle [%s]".format(ref, msg) - else "Actor does not handle [%s]".format(msg) - +class DeathPactException(ref: ActorRef = null) extends Exception { override def fillInStackTrace() = this //Don't waste cycles generating stack trace } +/** + * Message that is sent to a watching actor when the watched actor terminates. + */ case class Terminated(actor: ActorRef) diff --git a/src/actors-migration/scala/actors/Timeout.scala b/src/actors-migration/scala/actors/Timeout.scala index bb3c8c0476..0d9532a14b 100644 --- a/src/actors-migration/scala/actors/Timeout.scala +++ b/src/actors-migration/scala/actors/Timeout.scala @@ -1,6 +1,11 @@ -/** - * Copyright (C) 2009-2011 Typesafe Inc. - */ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + package scala.actors import scala.concurrent.util.Duration diff --git a/src/actors/scala/actors/ReplyReactor.scala b/src/actors/scala/actors/ReplyReactor.scala index 0ffbbd3cce..83d7ba0f7f 100644 --- a/src/actors/scala/actors/ReplyReactor.scala +++ b/src/actors/scala/actors/ReplyReactor.scala @@ -7,10 +7,7 @@ \* */ package scala.actors -@deprecated("Scala Actors are beeing removed from the standard library. Please refer to the migration guide.", "2.10") +@deprecated("Scala Actors are being removed from the standard library. Please refer to the migration guide.", "2.10") trait ReplyReactor extends InternalReplyReactor { - - protected[actors] def sender: OutputChannel[Any] = super.internalSender - + protected[actors] def sender: OutputChannel[Any] = super.internalSender } - -- cgit v1.2.3