The answer lies in UnstartedCell, but beware that this code may be morally challenging: it uses a Lock ;-)
Regards, Roland Sent from my iPhone > On 21 Dec 2016, at 08:02, stella <interstel...@gmail.com> wrote: > > I'm trying to understand how actor creating is being performed internally. > So, once we created our ActorSystem object we can start a top level actor > like this: > > val system = ActorSystem("system", config) > val ref = system.actorOf(MyActor.props, "myactor") > > > Internally, it will invoke ActorRefProvider::actorOf(ActorSystemImpl, Props, > InternalActorRef, ActorPath, Boolean, Option[Deoploy], Boolean, Boolean) > which in my case is ended up with invocation > > if (async) new RepointableActorRef(system, props2, dispatcher, mailboxType, > supervisor, path).initialize(async) > > where async=true. The initialize method, in turn invoke > > supervisor.sendSystemMessage(Supervise(this, async)) > > which ends up with: > > protected[akka] def systemDispatch(receiver: ActorCell, invocation: > SystemMessage): Unit = { > val mbox = receiver.mailbox > mbox.systemEnqueue(receiver.self, invocation) > registerForExecution(mbox, false, true) > } > > So, in effect, creating RepointableActorRef asynchronously means sending a > system message to a supervisor which results in creating the actor instance > itself, invoking the startup hook and so forth. > > QUESTION: Why there is no race condition here when we create ActorRef that > way and immediately send a message to the actor? What thing does guarantee > the memory consistency? > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to akka-user+unsubscr...@googlegroups.com. > To post to this group, send email to akka-user@googlegroups.com. > Visit this group at https://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.