/// <summary> /// Clears this instance by removing all stored items.<para/> /// If a Default Intance Dispose method was provided, it will be called for /// every remove item. /// </summary> public static void Clear() { if (DefaultInstanceDispose != null) { T item; while (m_bag.TryPop(out item)) { DefaultInstanceDispose(item); } } m_bag.Clear(); }
private bool disposedValue = false; // 要检测冗余调用 protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { mPool.Clear(); } disposedValue = true; } }
public void ResetPool(Func <T> newObjectGen) { objectGenerator = newObjectGen; objects.Clear(); }
public void Clear() { _stack.Clear(); }