public void ReturnObject(T obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("Object can not be null");
            }

            if (_currAllocatedObjects < _maxAllocatedObjects)
            {
                Interlocked.Increment(ref _currAllocatedObjects);
                _storage.Enqueue(obj);
            }
        }
Beispiel #2
0
        public void ReturnBytes(byte[] bytes)
        {
            LocklessQueue <ImmutableTimestampedItem <byte[]> > container = this.FindExactContainer(bytes.Length);

            if (container != null)
            {
                if (_currAllocatedBytes < _maxAllocatedBytes)
                {
                    Interlocked.Add(ref _currAllocatedBytes, bytes.Length);
                    container.Enqueue(new ImmutableTimestampedItem <byte[]>(bytes));
                }
            }
        }
        public void ReturnBytes(byte[] bytes)
        {
            LocklessQueue <byte[]> container = this.FindExactContainer(bytes.Length);

            if (container != null)
            {
                if (_currAllocatedBytes < _maxAllocatedBytes)
                {
                    Interlocked.Add(ref _currAllocatedBytes, bytes.Length);
                    container.Enqueue(bytes);
                }
            }
        }