public UserMessagesQueue GetQueue(ulong startPacketIndex, int queueLength) { var queue = Queues.FirstOrDefault(q => q.StartPacketIndex == startPacketIndex); if (queue == null) { queue = new UserMessagesQueue { StartPacketIndex = startPacketIndex, Messages = new UserMessage[queueLength] }; Queues.Add(queue); } return queue; }
public IEnumerable<UserMessage> ExtractMessagesFromQueue(UserMessagesQueue queue) { IEnumerable<UserMessage> messages; lock (this) { messages = queue.Messages.ToList(); Queues.Queues.Remove(queue); queue.Messages = null; } return messages; }