Ejemplo n.º 1
0
        /// <summary>
        /// 获取匹配值集合
        /// </summary>
        /// <param name="isValue">数据匹配器</param>
        /// <returns>匹配值集合</returns>
        public unsafe valueType[] GetFindArray(Func <valueType, bool> isValue)
        {
            if (Length == 0)
            {
                return(NullValue <valueType> .Array);
            }
            int           length = ((Length + 63) >> 6) << 3;
            UnmanagedPool pool   = AutoCSer.UnmanagedPool.GetDefaultPool(length);

            Pointer.Size buffer = pool.GetSize64(length);
            try
            {
                Memory.ClearUnsafe(buffer.ULong, length >> 3);
                return(getFindArray(isValue, new MemoryMap(buffer.Data)));
            }
            finally { pool.PushOnly(ref buffer); }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取匹配值集合
        /// </summary>
        /// <param name="isValue">数据匹配器</param>
        /// <returns>匹配值集合</returns>
        public unsafe T[] GetFindArray(Func <T, bool> isValue)
        {
            if (Length == 0)
            {
                return(EmptyArray <T> .Array);
            }
            int           length = ((Length + 63) >> 6) << 3;
            UnmanagedPool pool   = UnmanagedPool.GetPool(length);

            AutoCSer.Memory.Pointer buffer = pool.GetMinSize(length);
            try
            {
                AutoCSer.Memory.Common.Clear(buffer.ULong, length >> 3);
                return(getFindArray(isValue, new MemoryMap(buffer.Data)));
            }
            finally { pool.Push(ref buffer); }
        }
        /// <summary>
        /// 获取非托管内存池
        /// </summary>
        /// <param name="size">缓冲区字节大小</param>
        /// <returns>非托管内存池</returns>
        public static UnmanagedPool GetOrCreate(int size)
        {
            if (size <= 0)
            {
                throw new IndexOutOfRangeException("size" + size.toString() + " <= 0");
            }
            UnmanagedPool pool;

            Monitor.Enter(poolLock);
            if (pools.TryGetValue(size, out pool))
            {
                Monitor.Exit(poolLock);
            }
            else
            {
                try
                {
                    pools.Add(size, pool = new UnmanagedPool(size));
                }
                finally { Monitor.Exit(poolLock); }
            }
            return(pool);
        }
Ejemplo n.º 4
0
 static UnmanagedPool()
 {
     pools = AutoCSer.DictionaryCreator.CreateInt <UnmanagedPool>();
     pools.Add(TinySize, Tiny       = new UnmanagedPool(TinySize));
     pools.Add(DefaultSize, Default = new UnmanagedPool(DefaultSize));
 }
Ejemplo n.º 5
0
 private static void clearUnmanagedCache(int count)
 {
     UnmanagedPool.ClearCache(count);
 }