Пример #1
0
        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);
            }
        }
Пример #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));
                }
            }
        }
Пример #3
0
        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);
                }
            }
        }