Example #1
0
 /// <summary>
 /// 批量申请非托管内存
 /// </summary>
 /// <param name="isClear">是否需要清除</param>
 /// <param name="sizes">内存字节数集合</param>
 /// <returns>非托管内存起始指针</returns>
 internal static pointer[] GetStatic(bool isClear, params int[] sizes)
 {
     if (sizes.length() != 0)
     {
         int sum = 0;
         foreach (int size in sizes)
         {
             if (size < 0)
             {
                 log.Error.Throw(log.exceptionType.IndexOutOfRange);
             }
             checked { sum += size; }
         }
         pointer pointer = GetStatic(sum, isClear);
         byte *  data    = pointer.Byte;
         if (data != null)
         {
             int       index = 0;
             pointer[] datas = new pointer[sizes.Length];
             foreach (int size in sizes)
             {
                 datas[index++] = new pointer {
                     Data = data
                 };
                 data += size;
             }
             return(datas);
         }
     }
     return(null);
 }
Example #2
0
        public pointer TryGet()
        {
            pointer value = default(pointer);

            pool.TryGet(ref value);
            return(value);
        }
Example #3
0
        /// <summary>
        /// 获取缓冲区
        /// </summary>
        /// <returns>缓冲区,失败返回null</returns>
        public pointer TryGet()
        {
            pointer buffer = new pointer();

            Monitor.Enter(bufferLock);
            foreach (pointer data in buffers)
            {
                buffer = data;
                break;
            }
            if (buffer.Data != null)
            {
                buffers.Remove(buffer);
            }
            Monitor.Exit(bufferLock);
            return(buffer);
        }
Example #4
0
        static date()
        {
            int dataIndex = 0;

            pointer[] datas = unmanaged.Get(false, 7 * sizeof(int), 12 * sizeof(int));
            weekData  = datas[dataIndex++];
            monthData = datas[dataIndex++];

            int *write = weekData.Int;

            *write = 'S' + ('u' << 8) + ('n' << 16) + (',' << 24);
            *++write = 'M' + ('o' << 8) + ('n' << 16) + (',' << 24);
            *++write = 'T' + ('u' << 8) + ('e' << 16) + (',' << 24);
            *++write = 'W' + ('e' << 8) + ('d' << 16) + (',' << 24);
            *++write = 'T' + ('h' << 8) + ('u' << 16) + (',' << 24);
            *++write = 'F' + ('r' << 8) + ('i' << 16) + (',' << 24);
            *++write = 'S' + ('a' << 8) + ('t' << 16) + (',' << 24);

            write = monthData.Int;
            *write = 'J' + ('a' << 8) + ('n' << 16) + (' ' << 24);
            *++write = 'F' + ('e' << 8) + ('b' << 16) + (' ' << 24);
            *++write = 'M' + ('a' << 8) + ('r' << 16) + (' ' << 24);
            *++write = 'A' + ('p' << 8) + ('r' << 16) + (' ' << 24);
            *++write = 'M' + ('a' << 8) + ('y' << 16) + (' ' << 24);
            *++write = 'J' + ('u' << 8) + ('n' << 16) + (' ' << 24);
            *++write = 'J' + ('u' << 8) + ('l' << 16) + (' ' << 24);
            *++write = 'A' + ('u' << 8) + ('g' << 16) + (' ' << 24);
            *++write = 'S' + ('e' << 8) + ('p' << 16) + (' ' << 24);
            *++write = 'O' + ('c' << 8) + ('t' << 16) + (' ' << 24);
            *++write = 'N' + ('o' << 8) + ('v' << 16) + (' ' << 24);
            *++write = 'D' + ('e' << 8) + ('c' << 16) + (' ' << 24);

            nowTime        = DateTime.Now;
            timer.Elapsed += refreshTime;
            timer.Start();
        }
Example #5
0
 /// <summary>
 /// 指针位图
 /// </summary>
 /// <param name="map">位图指针,不能为null</param>
 public fixedMap(pointer map)
 {
     this.map = map.Byte;
 }
Example #6
0
 static number()
 {
     deBruijn32 = unmanaged.Get(32);
     byte* deBruijn32Data = deBruijn32.Byte;
     for (byte bit = 0; bit != 32; ++bit) deBruijn32Data[((1U << bit) * deBruijn32Number) >> 27] = bit;
     //deBruijn64 = new byte[64];
     //for (byte bit = 0; bit != 64; ++bit) deBruijn64[((1UL << bit) * deBruijn64Number) >> 58] = bit;
 }
Example #7
0
 /// <summary>
 /// 初始化ASCII位图
 /// </summary>
 /// <param name="map">位图指针</param>
 /// <param name="value">初始值集合</param>
 /// <param name="isUnsafe">初始值是否安全</param>
 public asciiMap(pointer map, string value, bool isUnsafe = true) : this(map.Byte, value, isUnsafe) { }
Example #8
0
 static String()
 {
     pinyins = unmanaged.Get((476 - 224 + 1) * sizeof(char));
     char* pinyinData = pinyins.Char;
     pinyinData['ā' - 224] = 'a';
     pinyinData['á' - 224] = 'a';
     pinyinData['ǎ' - 224] = 'a';
     pinyinData['à' - 224] = 'a';
     pinyinData['ē' - 224] = 'e';
     pinyinData['é' - 224] = 'e';
     pinyinData['ě' - 224] = 'e';
     pinyinData['è' - 224] = 'e';
     pinyinData['ī' - 224] = 'i';
     pinyinData['í' - 224] = 'i';
     pinyinData['ǐ' - 224] = 'i';
     pinyinData['ì' - 224] = 'i';
     pinyinData['ō' - 224] = 'o';
     pinyinData['ó' - 224] = 'o';
     pinyinData['ǒ' - 224] = 'o';
     pinyinData['ò' - 224] = 'o';
     pinyinData['ū' - 224] = 'u';
     pinyinData['ú' - 224] = 'u';
     pinyinData['ǔ' - 224] = 'u';
     pinyinData['ù' - 224] = 'u';
     pinyinData['ǘ' - 224] = 'v';
     pinyinData['ǚ' - 224] = 'v';
     pinyinData['ǜ' - 224] = 'v';
 }
Example #9
0
        static date()
        {
            int dataIndex = 0;
            pointer[] datas = unmanaged.Get(false, 7 * sizeof(int), 12 * sizeof(int));
            weekData = datas[dataIndex++];
            monthData = datas[dataIndex++];

            int* write = weekData.Int;
            *write = 'S' + ('u' << 8) + ('n' << 16) + (',' << 24);
            *++write = 'M' + ('o' << 8) + ('n' << 16) + (',' << 24);
            *++write = 'T' + ('u' << 8) + ('e' << 16) + (',' << 24);
            *++write = 'W' + ('e' << 8) + ('d' << 16) + (',' << 24);
            *++write = 'T' + ('h' << 8) + ('u' << 16) + (',' << 24);
            *++write = 'F' + ('r' << 8) + ('i' << 16) + (',' << 24);
            *++write = 'S' + ('a' << 8) + ('t' << 16) + (',' << 24);

            write = monthData.Int;
            *write = 'J' + ('a' << 8) + ('n' << 16) + (' ' << 24);
            *++write = 'F' + ('e' << 8) + ('b' << 16) + (' ' << 24);
            *++write = 'M' + ('a' << 8) + ('r' << 16) + (' ' << 24);
            *++write = 'A' + ('p' << 8) + ('r' << 16) + (' ' << 24);
            *++write = 'M' + ('a' << 8) + ('y' << 16) + (' ' << 24);
            *++write = 'J' + ('u' << 8) + ('n' << 16) + (' ' << 24);
            *++write = 'J' + ('u' << 8) + ('l' << 16) + (' ' << 24);
            *++write = 'A' + ('u' << 8) + ('g' << 16) + (' ' << 24);
            *++write = 'S' + ('e' << 8) + ('p' << 16) + (' ' << 24);
            *++write = 'O' + ('c' << 8) + ('t' << 16) + (' ' << 24);
            *++write = 'N' + ('o' << 8) + ('v' << 16) + (' ' << 24);
            *++write = 'D' + ('e' << 8) + ('c' << 16) + (' ' << 24);

            nowTime = DateTime.Now;
            timer.Elapsed += refreshTime;
            timer.Start();
        }
Example #10
0
 /// <summary>
 /// 指针位图
 /// </summary>
 /// <param name="map">位图指针,不能为null</param>
 public fixedMap(pointer map)
 {
     this.map = map.Byte;
 }
Example #11
0
 public void Push(ref pointer buffer)
 {
     push(ref buffer.Data);
 }
Example #12
0
        public pointer Get()
        {
            pointer data = TryGet();

            return(data.Data != null ? data : unmanaged.Get(Size, false).Pointer);
        }