예제 #1
0
            public void OnError(Exception error)
            {
                var inner = new MaybeInnerObserver <T>(downstream);

                if (Interlocked.CompareExchange(ref fallbackObserver, inner, null) == null)
                {
                    var fb = fallback;
                    fallback = null;

                    fb.Subscribe(inner);
                }
            }
            void Next()
            {
                var o = main;

                main = null;

                var inner = new MaybeInnerObserver <T>(downstream);

                if (DisposableHelper.Replace(ref upstream, inner))
                {
                    o.Subscribe(inner);
                }
            }
예제 #3
0
            public void OnError(Exception error)
            {
                var fb = default(IMaybeSource <T>);

                try
                {
                    fb = RequireNonNullRef(handler(error), "The handler returned a null IMaybeSource");
                }
                catch (Exception ex)
                {
                    downstream.OnError(new AggregateException(error, ex));
                    return;
                }

                var inner = new MaybeInnerObserver <T>(downstream);

                if (Interlocked.CompareExchange(ref fallbackObserver, inner, null) == null)
                {
                    fb.Subscribe(inner);
                }
            }
예제 #4
0
            internal void Run()
            {
                if (Interlocked.CompareExchange(ref exclude, 1, 0) == 0)
                {
                    DisposableHelper.Dispose(ref upstream);

                    var c = fallback;

                    if (c == null)
                    {
                        downstream.OnError(new TimeoutException());
                    }
                    else
                    {
                        fallback = null;

                        var inner = new MaybeInnerObserver <T>(downstream);
                        if (Interlocked.CompareExchange(ref fallbackObserver, inner, null) == null)
                        {
                            c.Subscribe(inner);
                        }
                    }
                }
            }