コード例 #1
0
        //TODO this method currently is not queuing messages properly
        public void AddToQueue(String item, MessageType messageType)
        {
            byte[] messageBytes = item.GetBytes();
            int    length       = messageBytes.Length;

            EventCaller eventItem = GetEventAllocation(messageType, length);

            _haywireBridge._processorViewAccessor.WriteArray(eventItem.OffsetPosition, messageBytes, 0, messageBytes.Length);

            EventsToSendQueue.Enqueue(eventItem);
        }
コード例 #2
0
        private void PerformanceTestProcessIncomingEvent(EventCaller eventObject)
        {
            //decide what to do based on message type

            if (eventObject.MessageType % 2 == 0)
            {
                //is a response; ignore
                if (eventObject.MessageType != 0)
                {
                    _memoryManagmentFactory.ReturnAllocation(new MemoryAllocation(eventObject));
                }

                //TODO memory pool release
            }
            else
            {
                MessageType messageType = (MessageType)eventObject.MessageType;
                switch (messageType)
                {
                case MessageType.Echo:
                    Byte[] data = new byte[eventObject.MessageLength];
                    _processorViewAccessor.ReadArray(eventObject.OffsetPosition, data, 0, eventObject.MessageLength);
                    _memoryManagmentFactory.ReturnAllocation(new MemoryAllocation(eventObject));

                    String message = data.GetString();
                    Console.WriteLine(message);

                    RaiseEvent(message, MessageType.EchoReply);
                    break;


                case MessageType.Default:
                default:
                    //ignore

                    break;
                }
            }


            //get the string from memory
            //Convert bytes to string


            //respond back
        }
コード例 #3
0
 private void DebugProcessIncomingEvent(EventCaller q)
 {
     Console.WriteLine(q.MessageCounter);
 }
コード例 #4
0
 private void SubscribedProcessIncomingEvent(EventCaller obj)
 {
     ProcessEventDelegates[(MessageType)obj.MessageType].Invoke(obj, _processorViewAccessor);
 }
コード例 #5
0
 private void ProcessIncomingEventDoNothing(EventCaller eventCaller, MemoryMappedViewAccessor accessor)
 {
     //Do Nothing
 }
コード例 #6
0
 private void NormalProcessIncomingEvent(EventCaller obj)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
 public MemoryAllocation(EventCaller eventObject)
 {
     Offset    = eventObject.OffsetPosition;
     Lenght    = eventObject.MemoryAllocationLength;
     NextBlock = Offset + Lenght;
 }