public override void CleanUp()
{
var actorCell = ActorCell;
if (actorCell != null) // actor is null for the deadLetterMailbox
{
var deadLetterMailbox = actorCell.System.Mailboxes.DeadLetterMailbox;
Envelope envelope;
while (_systemMessages.TryDequeue(out envelope))
{
deadLetterMailbox.Post(actorCell.Self, envelope);
}
while (_userMessages.TryDequeue(out envelope))
{
deadLetterMailbox.Post(actorCell.Self, envelope);
}
}
//Akka JVM code:
// if (actor ne null) { // actor is null for the deadLetterMailbox
// val dlm = actor.dispatcher.mailboxes.deadLetterMailbox
// var messageList = systemDrain(new LatestFirstSystemMessageList(NoMessage))
// while (messageList.nonEmpty) {
// // message must be “virgin” before being able to systemEnqueue again
// val msg = messageList.head
// messageList = messageList.tail
// msg.unlink()
// dlm.systemEnqueue(actor.self, msg)
// }
// if (messageQueue ne null) // needed for CallingThreadDispatcher, which never calls Mailbox.run()
// messageQueue.cleanUp(actor.self, actor.dispatcher.mailboxes.deadLetterMailbox.messageQueue)
// }
}