Clarifying setReceiveTimeout examples after review

This commit is contained in:
Viktor Klang 2012-10-15 13:49:12 +02:00
parent 0ab417b2c1
commit dbad8c85f6
2 changed files with 4 additions and 3 deletions

View file

@ -18,10 +18,11 @@ public class MyReceivedTimeoutUntypedActor extends UntypedActor {
public void onReceive(Object message) {
if (message.equals("Hello")) {
// To set in a response to a message
getContext().setReceiveTimeout(Duration.parse("30 seconds"));
getContext().setReceiveTimeout(Duration.parse("10 seconds"));
getSender().tell("Hello world", getSelf());
} else if (message == ReceiveTimeout.getInstance()) {
// To turn it off
getContext().setReceiveTimeout(Duration.Undefined());
throw new RuntimeException("received timeout");
} else {
unhandled(message);

View file

@ -274,9 +274,9 @@ class ActorDocSpec extends AkkaSpec(Map("akka.loglevel" -> "INFO")) {
// To set an initial delay
context.setReceiveTimeout(30 milliseconds)
def receive = {
case "Hello"
case "Hello"
// To set in a response to a message
context.setReceiveTimeout(30 milliseconds)
context.setReceiveTimeout(100 milliseconds)
case ReceiveTimeout
// To turn it off
context.setReceiveTimeout(Duration.Undefined)