示例#1
0
            public void Free(PoolBufferInstance buffer)
            {
                Interlocked.Increment(ref this._freeCount);
                if (this.Size != buffer.Buffer.Length)
                {
                    throw new ArgumentException("Invalid buffer size", "buffer");
                }
                bool lockTaken = false;
                Stack <PoolBufferInstance> stack = null;

                try
                {
                    Monitor.Enter((object)(stack = this._pool), ref lockTaken);
                    this._pool.Push(buffer);
                }
                finally
                {
                    if (lockTaken)
                    {
                        Monitor.Exit((object)stack);
                    }
                }
            }