Closes #3185. Review by plocinic.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@21205 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
phaller 2010-03-17 11:07:50 +00:00
parent 60cd26417f
commit 8e242b4b0e
3 changed files with 46 additions and 0 deletions

View File

@ -271,6 +271,8 @@ trait Reactor[Msg >: Null] extends OutputChannel[Msg] with Combinators {
private[actors] def terminated() {
synchronized {
_state = Actor.State.Terminated
// reset waitingFor, otherwise getState returns Suspended
waitingFor = Reactor.waitingForNone
}
scheduler.terminated(this)
}

View File

@ -0,0 +1,2 @@
Done
Terminated

View File

@ -0,0 +1,42 @@
import scala.actors.{Actor, Exit}
import scala.actors.Actor._
object Slave extends Actor {
def act() {
loop {
react {
case 'doWork =>
println("Done")
reply('done)
}
}
}
}
object Master extends Actor {
def act() {
link(Slave)
Slave ! 'doWork
react {
case 'done =>
throw new Exception("Master crashed")
}
}
}
object Test {
def main(args: Array[String]) {
actor {
self.trapExit = true
link(Slave)
Slave.start()
Master.start()
react {
case Exit(from, reason) if (from == Slave) =>
println(Slave.getState)
}
}
}
}