Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stream"></param>
        public void Load(System.IO.Stream stream)
        {
            mHead.Clear();
            mData.Clear();
            mAvaiableDataLen = 48;
            if (stream.Length < TagTotalCount * 8)
            {
                return;
            }

            byte[] bvals = System.Buffers.ArrayPool <byte> .Shared.Rent(4);

            //var br = new System.IO.BinaryReader(stream);
            stream.Read(bvals, 0, 4);
            var datasize = BitConverter.ToInt32(bvals, 0);

            mHead.ReadFromStream(stream, datasize);
            stream.Read(bvals, 0, 4);
            datasize = BitConverter.ToInt32(bvals, 0);

            mData.ReadFromStream(stream, datasize);
            mAvaiableDataLen = datasize;

            System.Buffers.ArrayPool <byte> .Shared.Return(bvals);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="block"></param>

        public void Release(MarshalMemoryBlock block)
        {
            lock (mFreePools)
            {
                var size = (int)block.AllocSize;
                if (mFreePools.ContainsKey(size))
                {
                    var vv = mFreePools[size];
                    vv.Enqueue(block);
                    block.Clear();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="memory"></param>
        public void ClearMemoryHisData(MarshalMemoryBlock memory)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            memory.Clear();
            memory.WriteByteDirect(0, 0);
            //foreach(var vv in mHisTags)
            //{
            //    vv.Value.ClearDataValue(memory);
            //}
            sw.Stop();
            LoggerService.Service.Info("Record", "清空数据区耗时:" + sw.ElapsedMilliseconds);
        }