示例#1
0
 public Enumerator(PullMergeSort <T> parent, IEnumerable <IEnumerator <T> > inputs)
 {
     _parent = parent;
     _inputs = new List <Reader>();
     foreach (var i in inputs)
     {
         _inputs.Add(new Reader(i));
     }
 }
示例#2
0
        /// <summary>
        ///     Starts the playback and returns immediately
        ///     The main use case is real-time feeds.
        /// </summary>
        public void Start()
        {
            foreach (IInputStream i in _inputs)
            {
                i.StartTime = StartTime;
                i.EndTime   = EndTime;

                if (KnownTypes == null)
                {
                    continue;
                }

                foreach (Type t in KnownTypes)
                {
                    i.AddKnownType(t);
                }
            }

            if (_inputs.Count == 0)
            {
                throw new Exception("No input sequences were added to the Playback");
            }

            if (_inputs.Count > 1)
            {
                IEnumerator <Timestamped <object> >[] queues = (from i in _inputs select i.Output).ToArray();
                _mergesort = new PullMergeSort <Timestamped <object> >(e => e.Timestamp.DateTime, queues);
                _timeSource.Connect();
                _pumpStart = new ManualResetEvent(false);
                _pump      = new OutputPump <Timestamped <object> >(_mergesort, _subject, _pumpStart);
                _pumpStart.Set();

                _stopwatch.Start();
                foreach (IInputStream i in _inputs)
                {
                    i.Start();
                }
            }
            else
            {
                _timeSource.Connect();
                IInputStream singleInput = _inputs[0];
                _stopwatch.Start();
                singleInput.Start(_subject);
            }
        }