protected override void Dispose(bool disposing) { // NB this method is called after ensuring that refcount is zero but before // cleaning the fields BufferPool <T> .Return(Array); base.Dispose(disposing); Pool.TryAdd(this); }
protected override void Dispose(bool disposing) { var array = Interlocked.Exchange(ref _array, null); if (array != null) { _disposed = true; BufferPool <T> .Return(array); } if (disposing) { Pool.TryAdd(this); } }
public override void Dispose(bool disposing) { var disposable = Inner as IDisposable; disposable?.Dispose(); Inner = null; var pooled = Pool.TryAdd(this as TImpl); // TODO review if (disposing && !pooled) { GC.SuppressFinalize(this); } }