Пример #1
0
        public virtual int ReturnBuffer <T>(T[] buffer)
        {
            AtomicCounter cnt;
            int           ret = 0;

            if (_cwt.TryGetValue(buffer, out cnt))
            {
                ret = Interlocked.Decrement(ref cnt.Count);
#if PRERELEASE
                // must not return buffer more times than it was taken/borrowed
                Trace.Assert(ret >= 0);
#endif
                if (ret == 0)
                {
                    var dblBuffer = buffer as double[];
                    if (dblBuffer != null)
                    {
                        _doublePool.ReturnBuffer(dblBuffer);
                    }
                    var byteBuffer = buffer as byte[];
                    if (byteBuffer != null)
                    {
                        _bytePool.ReturnBuffer(byteBuffer);
                    }
                }
            }
            return(ret);
        }
Пример #2
0
 public void ReturnBuffer <T>(T[] buffer)
 {
     if (typeof(T) == typeof(double))
     {
         _doublePool.ReturnBuffer(buffer as double[]);
     }
 }
Пример #3
0
            public override void ReturnBuffer(byte[] buffer)
            {
                if (buffer == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("buffer");
                }

                innerBufferManager.ReturnBuffer(buffer);
            }
Пример #4
0
 public void ReturnBuffer <T>(T[] buffer)
 {
     if (typeof(T) == typeof(double))
     {
         AtomicCounter cnt;
         if (_cwt.TryGetValue(buffer, out cnt))
         {
             cnt.Count--;
             _doublePool.ReturnBuffer(buffer as double[]);
         }
     }
 }
Пример #5
0
        private static void DeserializeGroupState(SessionState messageGroupState, XmlReader reader)
        {
            int num;

            byte[] numArray = SessionState.ReadBytes(reader, 9);
            long   num1     = BitConverter.ToInt64(numArray, 1);

            if (num1 == (long)0)
            {
                return;
            }
            InternalBufferManager bufferManager = ThrottledBufferManager.GetBufferManager();

            using (BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(1024, 2147483647, bufferManager))
            {
                byte[] numArray1 = bufferManager.TakeBuffer(1024);
                long   num2      = (long)0;
                try
                {
                    while (true)
                    {
                        int num3 = reader.ReadContentAsBase64(numArray1, 0, (int)numArray1.Length);
                        if (num3 == 0)
                        {
                            break;
                        }
                        num2 = num2 + (long)num3;
                        bufferedOutputStream.Write(numArray1, 0, num3);
                    }
                }
                finally
                {
                    bufferManager.ReturnBuffer(numArray1);
                }
                byte[] array = bufferedOutputStream.ToArray(out num);
                messageGroupState.Stream = new BufferedInputStream(array, num, bufferManager);
                if (num1 > (long)0 && num2 != num1)
                {
                    throw Fx.Exception.AsError(new InvalidOperationException(SRClient.FailedToDeSerializeEntireSessionStateStream), null);
                }
            }
        }