예제 #1
0
        public static ComputedAtom <T> CreatePooled <T>(ILifetimeScope scope, string debugName, Func <T> pull,
                                                        bool keepAlive)
        {
            var atomPool = Pool <T> .Atoms;

            ComputedAtom <T> atom;

            if (atomPool.Count > 0)
            {
                atom = atomPool.Pop();
                atom.Setup(debugName, pull, keepAlive);
            }
            else
            {
                atom = new ComputedAtom <T>(debugName, pull, keepAlive);
            }

            var disposerPool = Pool <T> .Recyclers;
            var disposer     = disposerPool.Count > 0 ? disposerPool.Pop() : new Recycler <T>();

            disposer.Setup(atom);

            scope.Lifetime.Register(disposer);

            return(atom);
        }
예제 #2
0
        public static ComputedAtom <T> Create <T>(ILifetimeScope scope, string debugName, Func <T> pull,
                                                  bool keepAlive)
        {
            var atom = new ComputedAtom <T>(debugName, pull, keepAlive);

            scope.Lifetime.Register(atom);
            return(atom);
        }
예제 #3
0
            public void Dispose()
            {
                ((IDisposable)_atom).Dispose();

                Pool <T> .Atoms.Push(_atom);

                Pool <T> .Recyclers.Push(this);

                _atom = null;
            }
예제 #4
0
 public void Setup(ComputedAtom <T> atom)
 {
     _atom = atom;
 }