コード例 #1
0
        public long Verify(int expectedCount, Action <TickIO, TickIO, long> assertTick, SymbolInfo symbol, int timeout, Action action)
        {
            if (debug)
            {
                log.Debug("Verify");
            }
            if (SyncTicks.Enabled)
            {
                tickSync = SyncTicks.GetTickSync(symbol.BinaryIdentifier);
            }
            long endTime = Factory.Parallel.TickCount + timeout * 1000;

            count = 0;
            while (Factory.Parallel.TickCount < endTime)
            {
                if (propagateException != null)
                {
                    throw propagateException;
                }
                try {
                    if (tickQueue.TryDequeue(ref tickBinary))
                    {
                        tickIO.Inject(tickBinary);
                        if (debug && countLog < 5)
                        {
                            log.Debug("Received a tick " + tickIO);
                            countLog++;
                        }
                        startTime = Factory.TickCount;
                        count++;
                        if (count > 0 && assertTick != null)
                        {
                            assertTick(tickIO, lastTick, symbol.BinaryIdentifier);
                        }
                        lastTick.Copy(tickIO);
                        if (!actionAlreadyRun && action != null)
                        {
                            actionAlreadyRun = true;
                            action();
                        }
                        if (SyncTicks.Enabled)
                        {
                            tickSync.RemoveTick();
                        }
                        if (count >= expectedCount)
                        {
                            break;
                        }
                    }
                    else
                    {
                        Thread.Sleep(100);
                    }
                } catch (QueueException ex) {
                    if (HandleQueueException(ex))
                    {
                        break;
                    }
                }
            }
            return(count);
        }
コード例 #2
0
        public long Verify(int expectedCount, Action <TickIO, TickIO, long> assertTick, int timeout, Action action)
        {
            if (debug)
            {
                log.Debug("Verify");
            }
            long endTime = Factory.Parallel.TickCount + timeout * 1000;

            count = 0;
            do
            {
                if (propagateException != null)
                {
                    throw propagateException;
                }
                try
                {
                    if (TryDequeueTick(ref tickBinary))
                    {
                        tickIO.Inject(tickBinary);
                        if (debug && countLog < 5)
                        {
                            log.Debug("Received a tick " + tickIO + " UTC " + tickIO.UtcTime);
                            countLog++;
                        }
                        else if (trace)
                        {
                            log.Trace("Received a tick " + tickIO + " UTC " + tickIO.UtcTime);
                        }
                        startTime = Factory.TickCount;
                        count++;
                        if (count > 0)
                        {
                            if (assertTick != null)
                            {
                                assertTick(tickIO, lastTick, symbol.BinaryIdentifier);
                            }
                            if (count % 10000 == 0)
                            {
                                log.Info("Read " + count + " ticks");
                            }
                        }
                        lastTick.Copy(tickIO);
                        if (!actionAlreadyRun && action != null)
                        {
                            actionAlreadyRun = true;
                            action();
                        }
                        if (SyncTicks.Enabled && symbolState == SymbolState.RealTime)
                        {
                            tickSync.RemoveTick(ref tickBinary);
                        }
                        if (count >= expectedCount)
                        {
                            break;
                        }
                    }
                    else
                    {
                        Thread.Sleep(100);
                        //if (queue.Count == 0 && SyncTicks.Enabled && SymbolState == SymbolState.RealTime)
                        //{
                        //    tickSync.RemoveTick();
                        //}
                    }
                }
                catch (QueueException ex)
                {
                    if (HandleQueueException(ex))
                    {
                        break;
                    }
                }
            } while (Factory.Parallel.TickCount < endTime);
            return(count);
        }