Exemplo n.º 1
0
 public void ReturnInstance(T instance)
 {
     ReturnInstanceTask?.Invoke(instance);
     if (objectStack.Count < targetCount)
     {
         objectStack.Push(instance);
     }
     else
     {
         DisposeInstanceTask?.Invoke(instance);
     }
 }
Exemplo n.º 2
0
        public void CreateInstance(int count)
        {
            if (count == 0)
            {
                return;
            }

            this.targetCount += count;
            for (int i = 0; i < count; ++i)
            {
                T instance;
                if (CreateInstanceMethod != null)
                {
                    instance = CreateInstanceMethod();
                }
                else
                {
                    instance = default(T);
                }
                ReturnInstanceTask?.Invoke(instance);
                objectStack.Push(instance);
            }
        }