Exemplo n.º 1
0
 public void OnPull()
 {
     if (_substreamWaitingToBePushed != null)
     {
         Push(_stage.Out, Source.FromGraph(_substreamWaitingToBePushed.Source));
         ScheduleOnce(_substreamWaitingToBePushed.Key.Value, _timeout);
         _substreamWaitingToBePushed = null;
     }
     else
     {
         if (HasNextElement)
         {
             var subSubstreamSource = _activeSubstreams[_nextElementKey.Value];
             if (subSubstreamSource.IsAvailable)
             {
                 subSubstreamSource.Push(_nextElementValue.Value);
                 ClearNextElement();
             }
         }
         else if (!HasBeenPulled(_stage.In))
         {
             TryPull(_stage.In);
         }
     }
 }
Exemplo n.º 2
0
            private void RunSubstream(TKey key, T value)
            {
                var substreamSource = new SubstreamSource(this, "GroupBySource " + NextId, key, value);

                _activeSubstreams.Add(key, substreamSource);
                _firstPushCounter++;
                if (IsAvailable(_stage.Out))
                {
                    Push(_stage.Out, Source.FromGraph(substreamSource.Source));
                    ScheduleOnce(key, _timeout);
                    _substreamWaitingToBePushed = null;
                }
                else
                {
                    SetKeepGoing(true);
                    _substreamsJustStarted.Add(substreamSource);
                    _substreamWaitingToBePushed = substreamSource;
                }
            }