Exemple #1
0
        public static void Free(BufferObject bufferObject)
        {
            string key = bufferObject.GetType().ToString();
            Stack <BufferObject> stack = GetCacheStack(key);

            lock (lockObject)
            {
                bufferObject.OnRecycle();
                stack.Push(bufferObject);
            }
        }
Exemple #2
0
        public static T Alloc <T>(int capacity) where T : BufferObject, new()
        {
            string key = typeof(T).ToString();

            BufferObject bufferObject = GetCacheObject(key);

            if (null != bufferObject)
            {
                bufferObject.OnAlloc();
                return(bufferObject as T);
            }

            T allocObject = new T();

            allocObject.Alloc(capacity);
            allocObject.OnAlloc();

            return(allocObject);
        }