Esempio n. 1
0
 public bool RemoveReactor(ReactorBase reactor)
 {
     lock (syncRoot)
     {
         return(reactors.Remove(reactor));
     }
 }
Esempio n. 2
0
 public void AddReactor(ReactorBase reactor)
 {
     lock (syncRoot)
     {
         reactors.Add(reactor);
     }
 }
Esempio n. 3
0
        public void Remove(ReactorBase reactor)
        {
            string referenceName = reactor.GetType().FullName + ":" + reactor.Name;

            if (reactors.TryRemove(referenceName, out Tuple <ReactorIsland, ReactorBase> removed))
            {
                reactor.AttachedToRepository(null, null);
                removed.Item1.RemoveReactor(removed.Item2);
            }
        }
Esempio n. 4
0
        public ReactorIsland Add(ReactorBase reactor, int reactorIslandIndex = -1)
        {
            string referenceName = reactor.GetType().FullName + ":" + reactor.Name;

            int index = reactorIslandIndex;

            if (index < 0)
            {
                index = Interlocked.Increment(ref currentIsland);
                index = index < 0 ? -index : index;
            }
            var island = islands[index % islands.Length];

            if (!reactors.TryAdd(referenceName, new Tuple <ReactorIsland, ReactorBase>(island, reactor)))
            {
                throw new ReactorException($"Failed to add reactor {referenceName}, it already exists");
            }

            reactor.AttachedToRepository(Resolve(reactor.GetType(), reactor.Name), this);
            island.AddReactor(reactor);

            return(island);
        }
Esempio n. 5
0
 public static ReactorIsland AddToGlobal(ReactorBase reactor)
 {
     return(Global.Add(reactor));
 }
Esempio n. 6
0
 public LocalReactorReference(string name, ReactorBase reactor)
 {
     Reference    = name;
     this.reactor = reactor;
 }