Beispiel #1
0
        private static void WriteOneCacheNotifyData(MemoryMappedViewAccessor accessor, ref CacheNotifyDataMapInfo mapInfo, CacheNotifyData notifyData, long currentTicks)
        {
            if (mapInfo.Pointer >= CacheNotifyDataMapInfo.CacheDataItemCount)
            {
                mapInfo.Pointer = 0;
            }

            long startPointer = Marshal.SizeOf(typeof(CacheNotifyDataMapInfo)) +
                                mapInfo.Pointer * (Marshal.SizeOf(typeof(CacheNotifyDataMapItem)) + CacheNotifyDataMapInfo.CacheDataBlockSize);

            byte[] data = notifyData.ToBytes();

            CacheNotifyDataMapItem item = new CacheNotifyDataMapItem();

            item.Ticks = currentTicks;
            item.Size  = data.Length;

            accessor.Write(startPointer, ref item);

            long dataPointer = startPointer + Marshal.SizeOf(typeof(CacheNotifyDataMapItem));

            accessor.WriteArray(dataPointer, data, 0, data.Length);

            mapInfo.Pointer++;

            accessor.Write(0, ref mapInfo);

            UdpCacheNotifier.TotalCounters.MmfSentItemsCounter.Increment();
            UdpCacheNotifier.TotalCounters.MmfSentCountPerSecond.Increment();

            UdpCacheNotifier.AppInstanceCounters.MmfSentItemsCounter.Increment();
            UdpCacheNotifier.AppInstanceCounters.MmfSentCountPerSecond.Increment();

            UdpCacheNotifier.TotalCounters.MmfCurrentPointer.RawValue       = mapInfo.Pointer;
            UdpCacheNotifier.AppInstanceCounters.MmfCurrentPointer.RawValue = mapInfo.Pointer;
        }
		private static void WriteOneCacheNotifyData(MemoryMappedViewAccessor accessor, ref CacheNotifyDataMapInfo mapInfo, CacheNotifyData notifyData, long currentTicks)
		{
			if (mapInfo.Pointer >= CacheNotifyDataMapInfo.CacheDataItemCount)
				mapInfo.Pointer = 0;

			long startPointer = Marshal.SizeOf(typeof(CacheNotifyDataMapInfo)) +
				mapInfo.Pointer * (Marshal.SizeOf(typeof(CacheNotifyDataMapItem)) + CacheNotifyDataMapInfo.CacheDataBlockSize);

			byte[] data = notifyData.ToBytes();

			CacheNotifyDataMapItem item = new CacheNotifyDataMapItem();

			item.Ticks = currentTicks;
			item.Size = data.Length;

			accessor.Write(startPointer, ref item);

			long dataPointer = startPointer + Marshal.SizeOf(typeof(CacheNotifyDataMapItem));

			accessor.WriteArray(dataPointer, data, 0, data.Length);

			mapInfo.Pointer++;

			accessor.Write(0, ref mapInfo);

			UdpCacheNotifier.TotalCounters.MmfSentItemsCounter.Increment();
			UdpCacheNotifier.TotalCounters.MmfSentCountPerSecond.Increment();

			UdpCacheNotifier.AppInstanceCounters.MmfSentItemsCounter.Increment();
			UdpCacheNotifier.AppInstanceCounters.MmfSentCountPerSecond.Increment();

			UdpCacheNotifier.TotalCounters.MmfCurrentPointer.RawValue = mapInfo.Pointer;
			UdpCacheNotifier.AppInstanceCounters.MmfCurrentPointer.RawValue = mapInfo.Pointer;
		}