コード例 #1
0
        public void Subscribe(ISignalObserver <T> observer)
        {
            if (maxConcurrency == int.MaxValue)
            {
                var parent = new MergeMaxCoordinator(observer, delayErrors);
                observer.OnSubscribe(parent);

                foreach (var source in sources)
                {
                    if (source == null)
                    {
                        parent.Error(new NullReferenceException());
                        return;
                    }
                    if (!parent.SubscribeTo(source))
                    {
                        return;
                    }
                }

                parent.SetDone();
            }
            else
            {
                var parent = new MergeLimitedCoordinator(observer, delayErrors, maxConcurrency, sources);
                observer.OnSubscribe(parent);

                parent.Drain();
            }
        }
コード例 #2
0
        public IDisposable Subscribe(IObserver <T> observer)
        {
            if (maxConcurrency == int.MaxValue)
            {
                var srcs = sources;
                var n    = sources.Length;

                var parent = new MergeAllCoordinator(observer, n, delayErrors);

                if (n != 0)
                {
                    parent.Subscribe(srcs, n);
                }
                else
                {
                    parent.Drain();
                }

                return(parent);
            }
            else
            {
                var parent = new MergeLimitedCoordinator(observer, sources, delayErrors, maxConcurrency);
                parent.Drain();
                return(parent);
            }
        }
コード例 #3
0
        public void Subscribe(ICompletableObserver observer)
        {
            if (maxConcurrency == int.MaxValue)
            {
                var parent = new MergeAllCoordinator(observer, delayErrors);
                observer.OnSubscribe(parent);
                parent.SubscribeAll(sources);
            }
            else
            {
                var en = default(IEnumerator <ICompletableSource>);
                try
                {
                    en = sources.GetEnumerator();
                }
                catch (Exception ex)
                {
                    DisposableHelper.Error(observer, ex);
                    return;
                }

                var parent = new MergeLimitedCoordinator(observer, en, delayErrors, maxConcurrency);
                observer.OnSubscribe(parent);
                parent.Drain();
            }
        }
コード例 #4
0
        public IDisposable Subscribe(IObserver <T> observer)
        {
            var en = default(IEnumerator <IMaybeSource <T> >);

            try
            {
                en = RequireNonNullRef(sources.GetEnumerator(), "The GetEnumerator returned a null IEnumerator");
            }
            catch (Exception ex)
            {
                observer.OnError(ex);
                return(DisposableHelper.EMPTY);
            }

            if (maxConcurrency == int.MaxValue)
            {
                var parent = new MergeAllCoordinator(observer, delayErrors);

                parent.Subscribe(en);

                return(parent);
            }
            else
            {
                var parent = new MergeLimitedCoordinator(observer, en, delayErrors, maxConcurrency);
                parent.Drain();
                return(parent);
            }
        }
コード例 #5
0
 public void Subscribe(ICompletableObserver observer)
 {
     if (maxConcurrency == int.MaxValue)
     {
         var parent = new MergeAllCoordinator(observer, delayErrors);
         observer.OnSubscribe(parent);
         parent.SubscribeAll(sources);
     }
     else
     {
         var parent = new MergeLimitedCoordinator(observer, sources, delayErrors, maxConcurrency);
         observer.OnSubscribe(parent);
         parent.Drain();
     }
 }
コード例 #6
0
        public void Subscribe(ISignalObserver <T> observer)
        {
            if (maxConcurrency == int.MaxValue)
            {
                var en = default(IEnumerator <IObservableSource <T> >);
                try
                {
                    en = RequireNonNullRef(sources.GetEnumerator(), "The GetEnumerator returned a null IEnumerator");
                }
                catch (Exception ex)
                {
                    DisposableHelper.Error(observer, ex);
                    return;
                }

                var parent = new MergeMaxCoordinator(observer, delayErrors);
                observer.OnSubscribe(parent);

                for (; ;)
                {
                    var b   = false;
                    var src = default(IObservableSource <T>);

                    try
                    {
                        b = en.MoveNext();
                        if (b)
                        {
                            src = RequireNonNullRef(en.Current, "The enumerator returned a null IObservableSource");
                        }
                    }
                    catch (Exception ex)
                    {
                        parent.Error(ex);
                        en.Dispose();
                        return;
                    }

                    if (b)
                    {
                        if (!parent.SubscribeTo(src))
                        {
                            en.Dispose();
                            break;
                        }
                    }
                    else
                    {
                        en.Dispose();
                        break;
                    }
                }

                parent.SetDone();
            }
            else
            {
                var en = default(IEnumerator <IObservableSource <T> >);
                try
                {
                    en = RequireNonNullRef(sources.GetEnumerator(), "The GetEnumerator returned a null IEnumerator");
                }
                catch (Exception ex)
                {
                    DisposableHelper.Error(observer, ex);
                    return;
                }

                var parent = new MergeLimitedCoordinator(observer, delayErrors, maxConcurrency, en);
                observer.OnSubscribe(parent);

                parent.Drain();
            }
        }