public void OnError(Exception error)
 {
     if (Interlocked.CompareExchange(ref wip, 1, 0) == 0)
     {
         if (!terminated)
         {
             terminated = true;
             Interlocked.Exchange(ref this.error, error);
             Volatile.Write(ref done, true);
             downstream.OnError(error);
             Dispose();
             if (Interlocked.Decrement(ref wip) == 0)
             {
                 return;
             }
         }
     }
     else
     {
         if (Interlocked.CompareExchange(ref this.error, error, null) == null)
         {
             Volatile.Write(ref done, true);
             if (Interlocked.Increment(ref wip) != 1)
             {
                 return;
             }
         }
         else
         {
             return;
         }
     }
     DrainLoop();
 }
 public void OnError(Exception ex)
 {
     if (delayErrors)
     {
         ExceptionHelper.AddException(ref errors, ex);
         Next();
     }
     else
     {
         downstream.OnError(ex);
     }
 }
 public void OnError(Exception ex)
 {
     if (won || parent.TryWin(index))
     {
         downstream.OnError(ex);
     }
 }
 internal void Handle(Task t)
 {
     if (t.IsCanceled)
     {
         observer?.OnError(new OperationCanceledException());
     }
     else
     if (t.IsFaulted)
     {
         observer?.OnError(t.Exception);
     }
     else
     {
         observer?.OnCompleted();
     }
 }
Esempio n. 5
0
 public void OnError(Exception ex)
 {
     if (remaining > 0)
     {
         downstream.OnError(ex);
     }
     // TODO what to do in this case?
 }
 public void Error(Exception error)
 {
     if (Volatile.Read(ref state) != Disposed)
     {
         Volatile.Write(ref state, Disposed);
         downstream.OnError(error);
     }
 }
Esempio n. 7
0
 public void OnError(Exception ex)
 {
     while (windows.Count != 0)
     {
         windows.Dequeue().OnError(ex);
     }
     downstream.OnError(ex);
 }
Esempio n. 8
0
 public void OnError(Exception ex)
 {
     if (upstream != DisposableHelper.DISPOSED)
     {
         DisposableHelper.WeakDispose(ref upstream);
         downstream.OnError(ex);
     }
 }
 public virtual void OnError(Exception error)
 {
     if (done)
     {
         return;
     }
     done = true;
     downstream.OnError(error);
 }
 public void OnError(Exception ex)
 {
     if (done)
     {
         return;
     }
     done = true;
     downstream.OnError(ex);
 }
            public void OnError(Exception error)
            {
                var d = Interlocked.Exchange(ref resource, DisposableHelper.DISPOSED);

                if (d != DisposableHelper.DISPOSED)
                {
                    downstream.OnError(error);
                    d?.Dispose();
                }
            }
Esempio n. 12
0
 public void OnError(Exception ex)
 {
     if (done)
     {
         return;
     }
     done = true;
     buffers.Clear();
     downstream.OnError(ex);
 }
 public static void OnError <T>(ISignalObserver <T> observer, Exception ex, ref int wip, ref Exception error)
 {
     if (Interlocked.CompareExchange(ref error, ex, null) == null)
     {
         if (Interlocked.Increment(ref wip) == 1)
         {
             observer.OnError(ex);
         }
     }
 }
Esempio n. 14
0
            public void OnError(Exception ex)
            {
                if (once)
                {
                    downstream.OnError(ex);
                }
                else
                {
                    var o = default(IObservableSource <T>);

                    try
                    {
                        o = ValidationHelper.RequireNonNullRef(handler(ex), "The handler returned a null IObservableSource");
                    }
                    catch (Exception exc)
                    {
                        downstream.OnError(new AggregateException(ex, exc));
                        return;
                    }
                    once = true;
                    o.Subscribe(this);
                }
            }
            internal void Run()
            {
                if (fused)
                {
                    return;
                }

                for (; ;)
                {
                    if (Volatile.Read(ref disposed))
                    {
                        enumerator?.Dispose();
                        enumerator = null;
                        break;
                    }
                    else
                    {
                        var v   = default(T);
                        var has = false;

                        try
                        {
                            has = enumerator.MoveNext();
                            if (has)
                            {
                                v = enumerator.Current;
                            }
                        }
                        catch (Exception ex)
                        {
                            downstream.OnError(ex);
                            break;
                        }

                        if (has)
                        {
                            downstream.OnNext(v);
                        }
                        else
                        {
                            downstream.OnCompleted();
                            Volatile.Write(ref disposed, true);
                        }
                    }
                }
            }
 public static void OnNext <T>(ISignalObserver <T> observer, T item, ref int wip, ref Exception error)
 {
     if (Interlocked.CompareExchange(ref wip, 1, 0) == 0)
     {
         observer.OnNext(item);
         if (Interlocked.Decrement(ref wip) != 0)
         {
             var ex = Volatile.Read(ref error);
             if (ex != ExceptionHelper.TERMINATED)
             {
                 observer.OnError(ex);
             }
             else
             {
                 observer.OnCompleted();
             }
         }
     }
 }
Esempio n. 17
0
            void OnErrorCore(Exception ex, bool callOnTerminate)
            {
                if (done)
                {
                    return;
                }
                done = true;

                try
                {
                    onError?.Invoke(ex);
                }
                catch (Exception exc)
                {
                    ex = new AggregateException(ex, exc);
                }

                if (callOnTerminate)
                {
                    try
                    {
                        onTerminate?.Invoke();
                    }
                    catch (Exception exc)
                    {
                        ex = new AggregateException(ex, exc);
                    }
                }

                downstream.OnError(ex);

                try
                {
                    onAfterTerminate?.Invoke();
                }
                catch (Exception)
                {
                    // TODO where to put these?
                }

                DoFinally();
            }
Esempio n. 18
0
 public void OnError(Exception ex)
 {
     queue.Clear();
     downstream.OnError(ex);
 }
 protected override void Error(Exception ex)
 {
     observer.OnError(ex);
 }
Esempio n. 20
0
 public void OnError(Exception ex)
 {
     window?.OnError(ex);
     window = null;
     downstream.OnError(ex);
 }
 internal static void Error <T>(this ISignalObserver <T> observer, Exception error)
 {
     observer.OnSubscribe(Empty <T>());
     observer.OnError(error);
 }
 public void OnError(Exception ex)
 {
     downstream.OnError(ex);
 }
 public void OnError(Exception ex)
 {
     DisposableHelper.Dispose(ref connection);
     downstream.OnError(ex);
 }
Esempio n. 24
0
 public void OnError(Exception ex)
 {
     downstream.OnError(ex);
     parent.Terminate();
 }
Esempio n. 25
0
 public static void EmitError <T>(this ISignalObserver <T> subject, Exception error, params T[] items)
 {
     Emit(subject, items);
     subject.OnError(error);
 }
 public void OnError(Exception error)
 {
     downstream.OnError(error);
     Dispose();
 }