Ejemplo n.º 1
0
        public static Unit RemoveWatcher(ProcessId watcher, ProcessId watching)
        {
            Process.logInfo(watcher + " stopped watching " + watching);

            lock (sync)
            {
                watchers = watchers.AddOrUpdate(watching,
                                                Some: set => set.Remove(watcher),
                                                None: () => Set.empty <ProcessId>()
                                                );

                if (watchers[watching].IsEmpty)
                {
                    watchers = watchers.Remove(watching);
                }

                watchings = watchings.AddOrUpdate(watcher,
                                                  Some: set => set.Remove(watching),
                                                  None: () => Set.empty <ProcessId>()
                                                  );

                if (watchings[watcher].IsEmpty)
                {
                    watchers = watchers.Remove(watcher);
                }
            }
            return(unit);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Disowns a child process
 /// </summary>
 public Unit UnlinkChild(ProcessId pid)
 {
     lock (sync)
     {
         children = children.Remove(pid.GetName().Value);
     }
     return(unit);
 }
Ejemplo n.º 3
0
 public static Unit RemoveDispatcher(ProcessName name)
 {
     lock (sync)
     {
         dispatchers = dispatchers.Remove(name);
     }
     return(unit);
 }
Ejemplo n.º 4
0
 static void RemoveLocalRegisteredById(ProcessId pid)
 {
     lock (regsync)
     {
         var names = registeredProcessIds.Find(pid).IfNone(Set.empty <ProcessName>());
         names.Iter(name =>
                    registeredProcessNames = registeredProcessNames.SetItem(name, registeredProcessNames[name].Remove(pid))
                    );
         registeredProcessIds = registeredProcessIds.Remove(pid);
     }
 }
Ejemplo n.º 5
0
        static void RemoveLocalRegisteredByName(ProcessName name)
        {
            lock (regsync)
            {
                var pids = registeredProcessNames.Find(name).IfNone(Set.empty <ProcessId>());

                pids.Iter(pid =>
                          registeredProcessIds = registeredProcessIds.SetItem(pid, registeredProcessIds[pid].Remove(name))
                          );
                registeredProcessNames = registeredProcessNames.Remove(name);
            }
        }
Ejemplo n.º 6
0
        static Unit RemoteDispatchTerminate(ProcessId terminating)
        {
            watchings.Find(terminating).IfSome(ws =>
            {
                var term = new TerminatedMessage(terminating);
                ws.Iter(w =>
                {
                    try
                    {
                        TellUserControl(w, term);
                    }
                    catch (Exception e)
                    {
                        Process.logErr(e);
                    }
                });
            });
            watchings.Remove(terminating);
            watchers = watchers.Remove(terminating);

            return(unit);
        }
Ejemplo n.º 7
0
        public void UnsubscribeChannel(string channelName)
        {
            channelName += Config.CatalogueName;

            Retry(() => redis.GetSubscriber().Unsubscribe(channelName));
            lock (subscriptions)
            {
                if (subscriptions.ContainsKey(channelName))
                {
                    subscriptions[channelName].OnCompleted();
                    subscriptions = subscriptions.Remove(channelName);
                }
            }
        }
Ejemplo n.º 8
0
        public static Map <A, Map <B, C> > Remove <A, B, C>(this Map <A, Map <B, C> > self, A outerKey, B innerKey)
        {
            var b = self.Find(outerKey);

            if (b.IsSome)
            {
                var bv = b.Value.Remove(innerKey);
                if (bv.Count() == 0)
                {
                    return(self.Remove(outerKey));
                }
                else
                {
                    return(self.SetItem(outerKey, bv));
                }
            }
            else
            {
                return(self);
            }
        }
Ejemplo n.º 9
0
        public static Map <A, Map <B, Map <C, D> > > Remove <A, B, C, D>(this Map <A, Map <B, Map <C, D> > > self, A aKey, B bKey, C cKey)
        {
            var b = self.Find(aKey);

            if (b.IsSome)
            {
                var c = b.Value.Find(bKey);
                if (c.IsSome)
                {
                    var cv = c.Value.Remove(cKey);
                    if (cv.Count() == 0)
                    {
                        var bv = b.Value.Remove(bKey);
                        if (b.Value.Count() == 0)
                        {
                            return(self.Remove(aKey));
                        }
                        else
                        {
                            return(self.SetItem(aKey, bv));
                        }
                    }
                    else
                    {
                        return(self.SetItem(aKey, b.Value.SetItem(bKey, cv)));
                    }
                }
                else
                {
                    return(self);
                }
            }
            else
            {
                return(self);
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Attempts to set a meta-data item.  If it is already set, nothing
 /// happens.
 ///
 /// This is for extending the default strategies behaviours and
 /// allows for state to survive in-between Process errors
 /// </summary>
 public StrategyState RemoveMetaData <T>(string key) =>
 With(Metadata: Metadata.Remove(key));
Ejemplo n.º 11
0
 public State RemoveMember(ProcessName nodeName) =>
 new State(Members.Remove(nodeName), System);
Ejemplo n.º 12
0
 public State ClearSession(string sid) =>
 new State(Sessions.Remove(sid), Metadata.Remove(sid));
Ejemplo n.º 13
0
 /// <summary>
 /// Atomically removes an item from the map
 /// If the key doesn't exists, the request is ignored.
 /// </summary>
 /// <param name="key">Key</param>
 /// <returns>New map with the item removed</returns>
 public static Map <K, V> remove <K, V>(Map <K, V> map, K key) =>
 map.Remove(key);
Ejemplo n.º 14
0
 public Unit RemoveSubscription(ProcessId pid)
 {
     subs.Find(pid.Path).IfSome(x => x.Dispose());
     subs = subs.Remove(pid.Path);
     return(unit);
 }