bool ReadNextMessage(IPositionedMessagesParser parser)
        {
            var tmp = parser.ReadNextAndPostprocess();

            lastReadMessage = tmp.Message;
            return(lastReadMessage != null);
        }
Beispiel #2
0
        void CreateUnderlyingParserAndInitJitterBuffer(Func <CreateParserParams, IPositionedMessagesParser> underlyingParserFactory)
        {
            CreateParserParams reversedParserParams = originalParams;

            reversedParserParams.Range     = null;
            reversedParserParams.Direction = GetOppositeDirection(originalParams.Direction);
            reversedParserParams.Flags    |= MessagesParserFlag.DisableMultithreading;

            int reversedMessagesQueued = 0;

            using (IPositionedMessagesParser reversedParser = underlyingParserFactory(reversedParserParams))
            {
                var tmp = new List <PostprocessedMessage>();
                for (int i = 0; i < jitterBufferSize; ++i)
                {
                    var tmpMsg = reversedParser.ReadNextAndPostprocess();
                    if (tmpMsg.Message == null)
                    {
                        break;
                    }
                    tmp.Add(tmpMsg);
                }
                tmp.Reverse();
                foreach (var tmpMsg in tmp)
                {
                    jitterBuffer.Enqueue(new Entry()
                    {
                        data = tmpMsg, index = currentIndex++
                    });
                    positionsBuffer.Push(new MessagesPositions(tmpMsg.Message));
                    ++reversedMessagesQueued;
                }
            }

            enumerator = ReadAddMessagesFromRangeCompleteJitterBuffer(underlyingParserFactory).GetEnumerator();
            for (int i = 0; i < jitterBufferSize; ++i)
            {
                var tmp = LoadNextMessage();
                reversedMessagesQueued -= tmp.DequeuedMessages;
                if (tmp.LoadedMessage == null)
                {
                    break;
                }
            }
            for (int i = 0; i < reversedMessagesQueued && jitterBuffer.Count > 0; ++i)
            {
                jitterBuffer.Dequeue();
                positionsBuffer.Pop();
            }
        }
 void ReadNextMessage(IPositionedMessagesParser parser)
 {
     try
     {
         var tmp = parser.ReadNextAndPostprocess();
         lastReadMessage = tmp.Message;
         if (lastReadMessage == null)
         {
             breakAlgorithm = true;
         }
     }
     catch (Exception e)
     {
         loadError      = e;
         breakAlgorithm = true;
     }
 }