Exemplo n.º 1
0
            /// <summary>Recycle the given byte array.</summary>
            /// <remarks>
            /// Recycle the given byte array.
            /// The byte array may or may not be allocated
            /// by the
            /// <see cref="NewByteArray(int)"/>
            /// method.
            /// This is a non-blocking call.
            /// </remarks>
            public override int Release(byte[] array)
            {
                Preconditions.CheckNotNull(array);
                if (Log.IsDebugEnabled())
                {
                    debugMessage.Get().Append("recycle: array.length=").Append(array.Length);
                }
                int freeQueueSize;

                if (array.Length == 0)
                {
                    freeQueueSize = -1;
                }
                else
                {
                    ByteArrayManager.FixedLengthManager manager = managers.Get(array.Length, false);
                    freeQueueSize = manager == null ? -1 : manager.Recycle(array);
                }
                if (Log.IsDebugEnabled())
                {
                    debugMessage.Get().Append(", freeQueueSize=").Append(freeQueueSize);
                    LogDebugMessage();
                }
                return(freeQueueSize);
            }