Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Gracefully terminating a Scala program after using Actor.self
- object EchoActor extends DaemonActor {
- def act() {
- loop {
- react {
- case (x: Any, respondTo: Actor) => {
- println("echoActor Got message " + x)
- respondTo ! "Echoing: " + x
- }
- case msg => println("Can't handle message " + msg)
- }
- }
- }
- }
- object TestRunner extends App {
- EchoActor.start()
- for (n <- 1 to 3) {
- EchoActor !("Time to echo", self)
- println(self.receiveWithin(1000) { case x => x})
- Actor.clearSelf() // <<-- This doesn't allow for graceful shutdown
- }
- Actor.resetProxy() // <<-- Neither does this
- println("Done.")
- }
- scala.actorsScheduler.shutdown()
Add Comment
Please, Sign In to add comment