Fix race condition during actor startup sequence
This PR is intended to fix the issue #159.
The race condition occurs when a msg is sent to an actor while it is still processing the actor.Initialized or actor.Started msg. This can easily happen when loading some state from a db when processing one of these startup msgs.
I am proposing that the inbox only be started after the actor has processed all the startup msgs. This requires some changes to the inbox:
- initialize the procStatus to "stopped"
- when Start() is called, transition to "starting" and then "idle" status, and then call schedule() to process queued msgs
I have added a test case to test the proper ordering of msgs under this scenario.
@anthdm
@troygilman0 Thanks for this! Very good work.
@anthdm please review
@tprifti Can your add your review as well?