Ejemplo n.º 1
0
        protected void RemWatcher(ActorRef watchee, ActorRef watcher)
        {
            var watcheeSelf = watchee.Equals(Self);
            var watcherSelf = watcher.Equals(Self);

            if (watcheeSelf && !watcherSelf)
            {
                if (_watchedBy.Contains(watcher))
                {
                    MaintainAddressTerminatedSubscription(() =>
                    {
                        _watchedBy.Remove(watcher);
                        if (System.Settings.DebugLifecycle)
                        {
                            Publish(new Debug(Self.Path.ToString(), Actor.GetType(), string.Format("no longer watched by {0}", watcher)));
                        }
                    }, watcher);
                }
            }
            else if (!watcheeSelf && watcherSelf)
            {
                Unwatch(watchee);
            }
            else
            {
                Publish(new Warning(Self.Path.ToString(), Actor.GetType(), string.Format("BUG: illegal Unwatch({0},{1} for {2}", watchee, watcher, Self)));
            }
        }
Ejemplo n.º 2
0
 private void SendTerminated(bool ifLocal, ActorRef watcher)
 {
     if (((ActorRefScope)watcher).IsLocal == ifLocal && !watcher.Equals(Parent))
     {
         ((InternalActorRef)watcher).Tell(new DeathWatchNotification(Self, true, false));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Processor for messages that are sent to the root system guardian
        /// </summary>
        /// <param name="message"></param>
        protected override bool Receive(object message)
        {
            //TODO need to add termination hook support
            var terminated = message as Terminated;

            if (terminated != null)
            {
                var terminatedActor = terminated.ActorRef;
                if (_userGuardian.Equals(terminatedActor))
                {
                    // time for the systemGuardian to stop, but first notify all the
                    // termination hooks, they will reply with TerminationHookDone
                    // and when all are done the systemGuardian is stopped
                    Context.Become(Terminating);
                    //TODO: Send TerminationHook to all registered termination hooks
                    //foreach(var terminationHook in _terminationHooks)
                    //{
                    //    terminationHook.Tell(terminationHook.Instance);
                    //}
                    StopWhenAllTerminationHooksDone();
                }
                else
                {
                    // a registered, and watched termination hook terminated before
                    // termination process of guardian has started
                    //TODO: Implement termination hook support
                    //_terminationHooks.Remove(terminatedActor)
                }
                return(true);
            }


            var stopChild = message as StopChild;

            if (stopChild != null)
            {
                Context.Stop(stopChild.Child);
                return(true);
            }
            var sender = Sender;

            //TODO: Implement termination hook support
            //var registerTerminationHook = message as RegisterTerminationHook;
            //if(registerTerminationHook != null && !ReferenceEquals(sender, Context.System.DeadLetters))
            //{
            //    _terminationHooks.Add(sender);
            //    Context.Watch(sender);
            //    return true;
            //}
            Context.System.DeadLetters.Tell(new DeadLetter(message, sender, Self), sender);
            return(true);
        }
Ejemplo n.º 4
0
        protected void RemWatcher(ActorRef watchee, ActorRef watcher)
        {
            var watcheeSelf = watchee.Equals(Self);
            var watcherSelf = watcher.Equals(Self);

            if (watcheeSelf && !watcherSelf)
            {
                if( _watchedBy.Contains(watcher)) MaintainAddressTerminatedSubscription(() =>
                {
                    _watchedBy.Remove(watcher);
                    if (System.Settings.DebugLifecycle) Publish(new Debug(Self.Path.ToString(), Actor.GetType(), string.Format("no longer watched by {0}", watcher)));
                } , watcher);
            }
            else if (!watcheeSelf && watcherSelf)
            {
                Unwatch(watchee);
            }
            else
            {
                Publish(new Warning(Self.Path.ToString(), Actor.GetType(), string.Format("BUG: illegal Unwatch({0},{1} for {2}", watchee, watcher, Self)));
            }
        }
Ejemplo n.º 5
0
 private void SendTerminated(bool ifLocal, ActorRef watcher)
 {
     if (((ActorRefScope)watcher).IsLocal && !watcher.Equals(Parent))
     {
         ((InternalActorRef)watcher).Tell(new DeathWatchNotification(Self, true, false));
     }
 }