private void AddCheckPoint(Guid instrumentId, DateTime checkTime, InstrumentStatus status, DateTime tradeDay, InstrumentTradingStatusBuilderProxy tradingStatus) { CheckPoint checkPoint = new CheckPoint(instrumentId, checkTime, status, tradeDay); var now = DateTime.Now; Logger.InfoFormat("add check point, {0}", checkPoint.ToString()); if (checkPoint.CheckTime <= now) { tradingStatus.Add(checkPoint.InstrumentId, checkPoint.Status, checkPoint.CheckTime, tradeDay); } else { if (_loadedInstrumentCheckPoints.Contains(new InstrumentCheckTimeKey(instrumentId, checkTime))) { return; } _loadedInstrumentCheckPoints.Add(new InstrumentCheckTimeKey(instrumentId, checkTime)); _checkPointHeap.Add(checkPoint); } }
private void DoTimePointCheck() { Logger.InfoFormat("check point counts = {0}", _checkPointHeap.Count); InstrumentTradingStatusBuilderProxy statusBuilder = null; lock (_mutex) { while (_checkPointHeap.Count > 0 && _checkPointHeap.Pick().CheckTime <= DateTime.Now) { CheckPoint point = _checkPointHeap.Pop(); _loadedInstrumentCheckPoints.Remove(new InstrumentCheckTimeKey(point.InstrumentId, point.CheckTime)); Logger.InfoFormat("Dequeue, current check point {0}", point); if (statusBuilder == null) { statusBuilder = new InstrumentTradingStatusBuilderProxy(); } statusBuilder.Add(point.InstrumentId, point.Status, point.CheckTime, point.TradeDay); } } if (statusBuilder != null) { this.OnInstrumentsStatusChanged(statusBuilder.StatusDict); } }