replace @volatile for childrenRefs with mailbox status read for memory consistency

This commit is contained in:
Roland 2011-12-05 16:18:56 +01:00
parent 0b5f8b083d
commit 13eb1b6c8b
2 changed files with 6 additions and 5 deletions

View file

@ -99,8 +99,6 @@ private[akka] class ActorCell(
var receiveTimeoutData: (Long, Cancellable) =
if (_receiveTimeout.isDefined) (_receiveTimeout.get, emptyCancellable) else emptyReceiveTimeoutData
// this is accessed without further synchronization during actorFor look-ups
@volatile
var childrenRefs: TreeMap[String, ChildRestartStats] = emptyChildrenRefs
def actorOf(props: Props, name: String): ActorRef = {

View file

@ -245,9 +245,12 @@ class LocalActorRef private[akka] (
* to inject synthetic actor paths like /temp.
*/
protected def getSingleChild(name: String): InternalActorRef = {
val children = actorCell.childrenRefs
if (children contains name) children(name).child.asInstanceOf[InternalActorRef]
else Nobody
if (actorCell.isTerminated) Nobody // read of the mailbox status ensures we get the latest childrenRefs
else {
val children = actorCell.childrenRefs
if (children contains name) children(name).child.asInstanceOf[InternalActorRef]
else Nobody
}
}
def getChild(names: Iterable[String]): InternalActorRef = {