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);
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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);
            }
        }