Akka.Actor.ActorCell.MaintainAddressTerminatedSubscription C# (CSharp) Method

MaintainAddressTerminatedSubscription() private method

Starts subscription to AddressTerminated if not already subscribing and the block adds a non-local ref to watching or watchedBy. Ends subscription to AddressTerminated if subscribing and the block removes the last non-local ref from watching and watchedBy.
private MaintainAddressTerminatedSubscription ( Action block, IActorRef change = null ) : void
block Action
change IActorRef
return void
        private void MaintainAddressTerminatedSubscription(Action block, IActorRef change = null)
        {
            if (IsNonLocal(change))
            {
                var had = HasNonLocalAddress();
                block();
                var has = HasNonLocalAddress();

                if (had && !has)
                    UnsubscribeAddressTerminated();
                else if (!had && has)
                    SubscribeAddressTerminated();
            }
            else
            {
                block();
            }
        }