Simple self-transitioning state machine implementation. Automatically changes state when the lifetime of a current state is over.