Beispiel #1
0
        public void Release(T element)
        {
            if (_stack.Count > 0 && ReferenceEquals(_stack.Peek(), element))
            {
                Log.Error("Internal error. Trying to destroy object that is already released to pool.");
            }

            _actionOnRelease.Call(element);
            _stack.Push(element);
        }
Beispiel #2
0
        public T Get()
        {
            T element;

            if (_stack.Count == 0)
            {
                element = new T();
                countAll++;
            }
            else
            {
                element = _stack.Pop();
            }

            _actionOnGet.Call(element);

            return(element);
        }