public void OnError(Exception e) { BackpressureHelper.Produced(ref requested, produced); Signal <T> v = Signal <T> .CreateOnError(e); value = v; BackpressureHelper.ScalarPostComplete(ref requested, v, actual); }
internal void Run() { if (Volatile.Read(ref requested) != 0L) { actual.OnNext(counter++); BackpressureHelper.Produced(ref requested, 1); } else { actual.OnError(BackpressureHelper.MissingBackpressureException()); } }
public void OnComplete() { if (done) { return; } BackpressureHelper.Produced(ref requested, produced); if (hasValue) { BackpressureHelper.ScalarPostComplete(ref requested, value, actual); } else { actual.OnComplete(); } }
public void OnError(Exception e) { T v; try { v = resumeValue(e); } catch (Exception ex) { actual.OnError(new AggregateException(e, ex)); return; } BackpressureHelper.Produced(ref requested, produced); v = value; BackpressureHelper.ScalarPostComplete(ref requested, v, actual); }
public void OnError(Exception e) { if (done) { return; } R v; try { v = onErrorCall(e); } catch (Exception ex) { actual.OnError(new AggregateException(e, ex)); return; } BackpressureHelper.Produced(ref requested, produced); last = v; BackpressureHelper.ScalarPostComplete(ref requested, v, actual); }
void Drain() { if (!QueueDrainHelper.Enter(ref wip)) { return; } int missed = 1; var a = actual; var q = queue; var bs = buffers; for (;;) { for (;;) { if (Volatile.Read(ref cancelled)) { foreach (var close in buffers) { close.Cancel(); } buffers.Clear(); queue.Clear(); return; } if (HandleException(a, q)) { return; } BufferWork bw; if (q.Poll(out bw)) { switch (bw.type) { case BufferWorkType.COMPLETE: { var c = Interlocked.Exchange(ref this.s, SubscriptionHelper.Cancelled); if (c == null) { q.Clear(); a.OnSubscribe(EmptySubscription <IList <T> > .Instance); } else { c.Cancel(); q.Clear(); } long p = produced; if (p != 0L) { BackpressureHelper.Produced(ref requested, produced); } BackpressureHelper.PostComplete(ref requested, actual, this, ref cancelled); return; } case BufferWorkType.OPEN: { var b = bw.buffer; bs.AddLast(b); IPublisher <V> p; try { p = close(b.u); if (p == null) { throw new NullReferenceException("The close function returned a null IPublisher"); } } catch (Exception exc) { ExceptionHelper.ThrowIfFatal(exc); ExceptionHelper.AddError(ref error, exc); HandleException(a, q); return; } p.Subscribe(b); } break; case BufferWorkType.CLOSE: { if (bs.Remove(bw.buffer)) { var b = bw.buffer.buffer; if (b.Count != 0) { produced++; a.OnNext(b); } else { Request(1); } } } break; default: { foreach (var buffer in bs) { buffer.buffer.Add(bw.value); } } break; } } else { break; } } missed = QueueDrainHelper.Leave(ref wip, missed); if (missed == 0) { break; } } }
public void OnComplete() { BackpressureHelper.Produced(ref requested, produced); BackpressureHelper.ScalarPostComplete(ref requested, value, actual); }