//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); }
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 }
private void DebugProcessIncomingEvent(EventCaller q) { Console.WriteLine(q.MessageCounter); }
private void SubscribedProcessIncomingEvent(EventCaller obj) { ProcessEventDelegates[(MessageType)obj.MessageType].Invoke(obj, _processorViewAccessor); }
private void ProcessIncomingEventDoNothing(EventCaller eventCaller, MemoryMappedViewAccessor accessor) { //Do Nothing }
private void NormalProcessIncomingEvent(EventCaller obj) { throw new NotImplementedException(); }
public MemoryAllocation(EventCaller eventObject) { Offset = eventObject.OffsetPosition; Lenght = eventObject.MemoryAllocationLength; NextBlock = Offset + Lenght; }