diff --git a/akka-actor-tests/src/test/scala/akka/actor/dispatch/DispatcherActorSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/dispatch/DispatcherActorSpec.scala index adeba45c81..c841cf216d 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/dispatch/DispatcherActorSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/dispatch/DispatcherActorSpec.scala @@ -81,10 +81,10 @@ class DispatcherActorSpec extends JUnitSuite { val latch = new CountDownLatch(100) val start = new CountDownLatch(1) val fastOne = actorOf( - Props(self ⇒ { case "sabotage" ⇒ works.set(false) }).withDispatcher(throughputDispatcher)) + Props(context ⇒ { case "sabotage" ⇒ works.set(false) }).withDispatcher(throughputDispatcher)) val slowOne = actorOf( - Props(self ⇒ { + Props(context ⇒ { case "hogexecutor" ⇒ start.await case "ping" ⇒ if (works.get) latch.countDown() }).withDispatcher(throughputDispatcher)) @@ -112,14 +112,14 @@ class DispatcherActorSpec extends JUnitSuite { val ready = new CountDownLatch(1) val fastOne = actorOf( - Props(self ⇒ { - case "ping" ⇒ if (works.get) latch.countDown(); self.stop() + Props(context ⇒ { + case "ping" ⇒ if (works.get) latch.countDown(); context.self.stop() }).withDispatcher(throughputDispatcher)) val slowOne = actorOf( - Props(self ⇒ { + Props(context ⇒ { case "hogexecutor" ⇒ ready.countDown(); start.await - case "ping" ⇒ works.set(false); self.stop() + case "ping" ⇒ works.set(false); context.self.stop() }).withDispatcher(throughputDispatcher)) slowOne ! "hogexecutor" diff --git a/akka-actor/src/main/scala/akka/actor/Actor.scala b/akka-actor/src/main/scala/akka/actor/Actor.scala index e9df81174b..1f241d9c66 100644 --- a/akka-actor/src/main/scala/akka/actor/Actor.scala +++ b/akka-actor/src/main/scala/akka/actor/Actor.scala @@ -358,7 +358,7 @@ object Actor { * */ def spawn(body: ⇒ Unit)(implicit dispatcher: MessageDispatcher = Dispatchers.defaultGlobalDispatcher) { - actorOf(Props(self ⇒ { case "go" ⇒ try { body } finally { self.stop() } }).withDispatcher(dispatcher)) ! "go" + actorOf(Props(context ⇒ { case "go" ⇒ try { body } finally { context.self.stop() } }).withDispatcher(dispatcher)) ! "go" } } @@ -546,15 +546,17 @@ trait Actor { *
* Is called on a crashed Actor right BEFORE it is restarted to allow clean * up of resources before Actor is terminated. + * By default it calls postStop() */ - def preRestart(reason: Throwable, message: Option[Any]) {} + def preRestart(reason: Throwable, message: Option[Any]) { postStop() } /** * User overridable callback. * * Is called right AFTER restart on the newly created Actor to allow reinitialization after an Actor crash. + * By default it calls preStart() */ - def postRestart(reason: Throwable) {} + def postRestart(reason: Throwable) { preStart() } /** * User overridable callback. diff --git a/akka-actor/src/main/scala/akka/actor/Props.scala b/akka-actor/src/main/scala/akka/actor/Props.scala index 3f39206d94..7090853498 100644 --- a/akka-actor/src/main/scala/akka/actor/Props.scala +++ b/akka-actor/src/main/scala/akka/actor/Props.scala @@ -58,7 +58,7 @@ object Props { */ def apply(creator: Creator[_ <: Actor]): Props = default.withCreator(creator.create) - def apply(behavior: ActorRef ⇒ Actor.Receive): Props = apply(new Actor { def receive = behavior(self) }) + def apply(behavior: ActorContext ⇒ Actor.Receive): Props = apply(new Actor { def receive = behavior(context) }) } /** diff --git a/akka-remote/src/main/scala/akka/remote/RemoteDaemon.scala b/akka-remote/src/main/scala/akka/remote/RemoteDaemon.scala index 9c06af9545..38283d1ffd 100644 --- a/akka-remote/src/main/scala/akka/remote/RemoteDaemon.scala +++ b/akka-remote/src/main/scala/akka/remote/RemoteDaemon.scala @@ -175,32 +175,32 @@ class RemoteDaemon extends Actor { def handle_fun0_unit(message: RemoteProtocol.RemoteDaemonMessageProtocol) { new LocalActorRef( Props( - self ⇒ { - case f: Function0[_] ⇒ try { f() } finally { self.stop() } + context ⇒ { + case f: Function0[_] ⇒ try { f() } finally { context.self.stop() } }).copy(dispatcher = computeGridDispatcher), newUuid.toString, systemService = true) ! payloadFor(message, classOf[Function0[Unit]]) } def handle_fun0_any(message: RemoteProtocol.RemoteDaemonMessageProtocol) { new LocalActorRef( Props( - self ⇒ { - case f: Function0[_] ⇒ try { reply(f()) } finally { self.stop() } + context ⇒ { + case f: Function0[_] ⇒ try { reply(f()) } finally { context.self.stop() } }).copy(dispatcher = computeGridDispatcher), newUuid.toString, systemService = true) forward payloadFor(message, classOf[Function0[Any]]) } def handle_fun1_arg_unit(message: RemoteProtocol.RemoteDaemonMessageProtocol) { new LocalActorRef( Props( - self ⇒ { - case (fun: Function[_, _], param: Any) ⇒ try { fun.asInstanceOf[Any ⇒ Unit].apply(param) } finally { self.stop() } + context ⇒ { + case (fun: Function[_, _], param: Any) ⇒ try { fun.asInstanceOf[Any ⇒ Unit].apply(param) } finally { context.self.stop() } }).copy(dispatcher = computeGridDispatcher), newUuid.toString, systemService = true) ! payloadFor(message, classOf[Tuple2[Function1[Any, Unit], Any]]) } def handle_fun1_arg_any(message: RemoteProtocol.RemoteDaemonMessageProtocol) { new LocalActorRef( Props( - self ⇒ { - case (fun: Function[_, _], param: Any) ⇒ try { reply(fun.asInstanceOf[Any ⇒ Any](param)) } finally { self.stop() } + context ⇒ { + case (fun: Function[_, _], param: Any) ⇒ try { reply(fun.asInstanceOf[Any ⇒ Any](param)) } finally { context.self.stop() } }).copy(dispatcher = computeGridDispatcher), newUuid.toString, systemService = true) forward payloadFor(message, classOf[Tuple2[Function1[Any, Any], Any]]) }