#2612 - Clarifying ReceiveTimeout semantics in the documentation.
This commit is contained in:
parent
b193a45235
commit
0ab417b2c1
4 changed files with 39 additions and 14 deletions
|
|
@ -269,11 +269,18 @@ class ActorDocSpec extends AkkaSpec(Map("akka.loglevel" -> "INFO")) {
|
|||
//#receive-timeout
|
||||
import akka.actor.ReceiveTimeout
|
||||
import scala.concurrent.util.duration._
|
||||
import scala.concurrent.util.Duration
|
||||
class MyActor extends Actor {
|
||||
// To set an initial delay
|
||||
context.setReceiveTimeout(30 milliseconds)
|
||||
def receive = {
|
||||
case "Hello" ⇒ //...
|
||||
case ReceiveTimeout ⇒ throw new RuntimeException("received timeout")
|
||||
case "Hello" ⇒
|
||||
// To set in a response to a message
|
||||
context.setReceiveTimeout(30 milliseconds)
|
||||
case ReceiveTimeout ⇒
|
||||
// To turn it off
|
||||
context.setReceiveTimeout(Duration.Undefined)
|
||||
throw new RuntimeException("Receive timed out")
|
||||
}
|
||||
}
|
||||
//#receive-timeout
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue