Merge pull request #1290 from akka/wip-3077-deprecate-isTerminated-√

#3077 - Deprecating ActorRef.isTerminated
This commit is contained in:
Viktor Klang (√) 2013-04-03 15:44:20 -07:00
commit 0d510ff031
12 changed files with 61 additions and 64 deletions

View file

@ -16,6 +16,7 @@ import akka.event.LoggingAdapter;
//#imports-prio-mailbox
import akka.dispatch.PriorityGenerator;
import akka.dispatch.UnboundedPriorityMailbox;
import akka.testkit.JavaTestKit;
import com.typesafe.config.Config;
//#imports-prio-mailbox
@ -83,6 +84,7 @@ public class DispatcherDocTestBase {
@Test
public void priorityDispatcher() throws Exception {
JavaTestKit probe = new JavaTestKit(system);
//#prio-dispatcher
// We create a new Actor that just prints out what it processes
@ -93,14 +95,17 @@ public class DispatcherDocTestBase {
LoggingAdapter log =
Logging.getLogger(getContext().system(), this);
{
getSelf().tell("lowpriority", getSelf());
getSelf().tell("lowpriority", getSelf());
getSelf().tell("highpriority", getSelf());
getSelf().tell("pigdog", getSelf());
getSelf().tell("pigdog2", getSelf());
getSelf().tell("pigdog3", getSelf());
getSelf().tell("highpriority", getSelf());
getSelf().tell(PoisonPill.getInstance(), getSelf());
for(Object msg : new Object[] {
"lowpriority",
"lowpriority",
"highpriority",
"pigdog",
"pigdog2",
"pigdog3",
"highpriority",
PoisonPill.getInstance() }) {
getSelf().tell(msg, getSelf());
}
}
public void onReceive(Object message) {
@ -122,11 +127,8 @@ public class DispatcherDocTestBase {
*/
//#prio-dispatcher
for (int i = 0; i < 10; i++) {
if (myActor.isTerminated())
break;
Thread.sleep(100);
}
probe.watch(myActor);
probe.expectMsgClass(Terminated.class);
}
static

View file

@ -3,12 +3,7 @@
*/
package docs.jrouting;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Kill;
import akka.actor.PoisonPill;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.actor.*;
import akka.remote.routing.RemoteRouterConfig;
import akka.routing.Broadcast;
import akka.routing.RoundRobinRouter;
@ -83,11 +78,11 @@ public class RouterViaProgramDocTestBase {
public void demonstratePoisonPill() {
new JavaTestKitWithSelf(system) {{
ActorRef router = system.actorOf(new Props(Echo.class).withRouter(new RoundRobinRouter(5)));
watch(router);
//#poisonPill
router.tell(PoisonPill.getInstance(), getSelf());
//#poisonPill
expectNoMsg(duration("1 seconds"));
Assert.assertTrue(router.isTerminated());
expectMsgClass(Terminated.class);
}};
}
@ -95,11 +90,11 @@ public class RouterViaProgramDocTestBase {
public void demonstrateBroadcastOfPoisonPill() {
new JavaTestKitWithSelf(system) {{
ActorRef router = system.actorOf(new Props(Echo.class).withRouter(new RoundRobinRouter(5)));
watch(router);
//#broadcastPoisonPill
router.tell(new Broadcast(PoisonPill.getInstance()), getSelf());
//#broadcastPoisonPill
expectNoMsg(duration("1 seconds"));
Assert.assertTrue(router.isTerminated());
expectMsgClass(Terminated.class);
}};
}
@ -107,11 +102,11 @@ public class RouterViaProgramDocTestBase {
public void demonstrateKill() {
new JavaTestKitWithSelf(system) {{
ActorRef router = system.actorOf(new Props(Echo.class).withRouter(new RoundRobinRouter(5)));
watch(router);
//#kill
router.tell(Kill.getInstance(), getSelf());
//#kill
expectNoMsg(duration("1 seconds"));
Assert.assertTrue(router.isTerminated());
expectMsgClass(Terminated.class);
}};
}
@ -119,11 +114,11 @@ public class RouterViaProgramDocTestBase {
public void demonstrateBroadcastOfKill() {
new JavaTestKitWithSelf(system) {{
ActorRef router = system.actorOf(new Props(Echo.class).withRouter(new RoundRobinRouter(5)));
watch(router);
//#broadcastKill
router.tell(new Broadcast(Kill.getInstance()), getSelf());
//#broadcastKill
expectNoMsg(duration("1 seconds"));
Assert.assertTrue(router.isTerminated());
expectMsgClass(Terminated.class);
}};
}