Пример #1
0
            public void OnError(Exception error)
            {
                var inner = new CompletableInnerObserver(downstream);

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

                    fb.Subscribe(inner);
                }
            }
Пример #2
0
            public void OnError(Exception error)
            {
                var fb = default(ICompletableSource);

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

                var inner = new CompletableInnerObserver(downstream);

                if (Interlocked.CompareExchange(ref fallbackObserver, inner, null) == null)
                {
                    fb.Subscribe(inner);
                }
            }
            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 CompletableInnerObserver(downstream);
                        if (Interlocked.CompareExchange(ref fallbackObserver, inner, null) == null)
                        {
                            c.Subscribe(inner);
                        }
                    }
                }
            }