public void Dispose() { MyIObjectPool.Return(impl); // Prevent continuing use, as the implementation object instance // could now be given out. impl = null; }
internal MyObjectImplGet() { lock (syncRoot) { if (pool.Count > 0) { return(pool.Dequeue()); } if (totalOjects >= maxObjects) { throw new PoolException("No objects available"); } var o = new MyObjectImpl(); totalObjects++; return(o); } }
public MyObject() { impl = MyObjectPool.Get(); }
internal void Return(MyObjectImpl obj) { lock (syncRoot) { pool.Enqueue(obj); } }