public virtual void Release(object instance) { rwlock.AcquireWriterLock(-1); try { if (!inUse.Contains(instance)) { throw new PoolException("Trying to release a component that does not belong to this pool"); } inUse.Remove(instance); if (available.Count < maxsize) { if (instance is IRecyclable) { (instance as IRecyclable).Recycle(); } available.Push(instance); } else { // Pool is full componentActivator.Destroy(instance); } } finally { rwlock.ReleaseWriterLock(); } }
public virtual bool Release(object instance) { using (rwlock.ForWriting()) { Burden burden; if (inUse.TryGetValue(instance, out burden) == false) { return(false); } inUse.Remove(instance); if (available.Count < maxsize) { if (instance is IRecyclable) { (instance as IRecyclable).Recycle(); } available.Push(burden); return(false); } } // Pool is full componentActivator.Destroy(instance); return(true); }
public virtual bool Release(object instance) { componentActivator.Destroy(instance); return true; }
public virtual void Release(object instance) { componentActivator.Destroy(instance); }