Adding Stash section in Actors docs (including docs for the Java API).
Example code added to ActorDocSpec/UntypedActorDocTestBase.
This commit is contained in:
parent
370c07b438
commit
8b17099f50
4 changed files with 139 additions and 0 deletions
|
|
@ -300,6 +300,26 @@ class ActorDocSpec extends AkkaSpec(Map("akka.loglevel" -> "INFO")) {
|
|||
val actor = system.actorOf(Props(new HotSwapActor), name = "hot")
|
||||
}
|
||||
|
||||
"using Stash" in {
|
||||
//#stash
|
||||
import akka.actor.Stash
|
||||
class ActorWithProtocol extends Actor with Stash {
|
||||
def receive = {
|
||||
case "open" ⇒
|
||||
unstashAll()
|
||||
context.become {
|
||||
case "write" ⇒ // do writing...
|
||||
case "close" ⇒
|
||||
unstashAll()
|
||||
context.unbecome()
|
||||
case msg ⇒ stash()
|
||||
}
|
||||
case msg ⇒ stash()
|
||||
}
|
||||
}
|
||||
//#stash
|
||||
}
|
||||
|
||||
"using watch" in {
|
||||
//#watch
|
||||
import akka.actor.{ Actor, Props, Terminated }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue