Esempio n. 1
0
        public static byte[] TakeBufferAndReturn(this ClearHelper ch, int bufferSize)
        {
            var result = ObjectPool.Default.TakeBuffer(bufferSize);

            if (null != result)
            {
                ch.Push(c => ObjectPool.Default.ReturnBuffer((byte[])c), result);
            }
            return(result);
        }
Esempio n. 2
0
        public static T TakeObjectAndReturn <T>(this ClearHelper ch) where T : class
        {
            var result = ObjectPool.TakeObject <T>();

            if (null != result)
            {
                ch.Push(c => ObjectPool.ReturnObject <object>(c), result);
            }
            return(result);
        }