public void Init(bool sendSupervise, Func<Mailbox> createMailbox /*, MailboxType mailboxType*/) //TODO: switch from Func<Mailbox> createMailbox to MailboxType mailboxType
{
var mailbox = createMailbox(); //Akka: dispatcher.createMailbox(this, mailboxType)
Dispatcher.Attach(this);
mailbox.Setup(Dispatcher);
mailbox.SetActor(this);
_mailbox = mailbox;
var createMessage = new Create();
// AKKA:
// /*
// * The mailboxType was calculated taking into account what the MailboxType
// * has promised to produce. If that was more than the default, then we need
// * to reverify here because the dispatcher may well have screwed it up.
// */
//// we need to delay the failure to the point of actor creation so we can handle
//// it properly in the normal way
//val actorClass = props.actorClass
//val createMessage = mailboxType match {
// case _: ProducesMessageQueue[_] if system.mailboxes.hasRequiredType(actorClass) ⇒
// val req = system.mailboxes.getRequiredType(actorClass)
// if (req isInstance mbox.messageQueue) Create(None)
// else {
// val gotType = if (mbox.messageQueue == null) "null" else mbox.messageQueue.getClass.getName
// Create(Some(ActorInitializationException(self,
// s"Actor [$self] requires mailbox type [$req] got [$gotType]")))
// }
// case _ ⇒ Create(None)
//}
//swapMailbox(mbox)
//mailbox.setActor(this)
//// ➡➡➡ NEVER SEND THE SAME SYSTEM MESSAGE OBJECT TO TWO ACTORS ⬅⬅⬅
//mailbox.systemEnqueue(self, createMessage)
var self = Self;
mailbox.Post(self, new Envelope {Message = createMessage, Sender = self});
if(sendSupervise)
{
Parent.SendSystemMessage(new Supervise(self, async: false));
}
}