public void OnNext(T t) { if (doneOverflow) { return; } if (!q.Offer(t)) { doneOverflow = true; s.Cancel(); Exception e = BackpressureHelper.MissingBackpressureException(); try { onOverflow?.Invoke(); } catch (Exception ex) { e = new AggregateException(e, ex); } error = e; Volatile.Write(ref done, true); } Drain(); }
public void OnNext(T t) { if (!queue.Offer(t)) { s.Cancel(); OnError(BackpressureHelper.MissingBackpressureException()); return; } Schedule(); }
public void OnNext(T t) { if (!queue.Offer(t)) { Cancel(); OnError(BackpressureHelper.MissingBackpressureException("Queue full?!")); return; } Drain(); }
public void OnNext(T t) { if (!q.Offer(t)) { OnError(BackpressureHelper.MissingBackpressureException()); } else { parent.Drain(); } }
public override void OnNext(T t) { if (fusionMode != FuseableHelper.ASYNC) { if (!queue.Offer(t)) { OnError(BackpressureHelper.MissingBackpressureException()); return; } } Drain(); }
public void OnNext(IOrderedItem <T> t) { if (fusionMode == FuseableHelper.NONE) { if (!queue.Offer(t)) { OnError(BackpressureHelper.MissingBackpressureException("Queue full?!")); return; } } parent.Drain(); }
internal void Enqueue(R value) { if (q.array == null) { q.InitVolatile(parent.bufferSize); } if (!q.Offer(value)) { OnError(BackpressureHelper.MissingBackpressureException()); } }
public void OnNext(T t) { if (sourceMode == FuseableHelper.NONE) { if (!queue.Offer(t)) { s.Cancel(); OnError(BackpressureHelper.MissingBackpressureException("Queue is full?!")); return; } } Schedule(); }
internal void Run() { if (Volatile.Read(ref requested) != 0L) { actual.OnNext(counter++); BackpressureHelper.Produced(ref requested, 1); } else { actual.OnError(BackpressureHelper.MissingBackpressureException()); } }
public void OnNext(T t) { if (!q.Offer(t)) { arbiter.Cancel(); OnError(BackpressureHelper.MissingBackpressureException()); } else { Drain(); } }
internal void InnerNext(JoinInnerSubscriber inner, T value) { if (QueueDrainHelper.TryEnter(ref wip)) { long r = Volatile.Read(ref requested); if (r != 0L) { actual.OnNext(value); if (r != long.MaxValue) { Interlocked.Decrement(ref requested); } inner.RequestOne(); } else { var q = inner.Queue(); if (!q.Offer(value)) { InnerError(BackpressureHelper.MissingBackpressureException("Queue full?!")); return; } } if (QueueDrainHelper.Leave(ref wip, 1) == 0) { return; } } else { var q = inner.Queue(); if (!q.Offer(value)) { InnerError(BackpressureHelper.MissingBackpressureException("Queue full?!")); return; } if (!QueueDrainHelper.Enter(ref wip)) { return; } } DrainLoop(); }
internal void Run() { if (Volatile.Read(ref requested)) { available = true; actual.OnNext(0); if (!DisposableHelper.IsDisposed(ref d)) { actual.OnComplete(); } } else { actual.OnError(BackpressureHelper.MissingBackpressureException()); } }
internal void OnNext(T value) { long r = Volatile.Read(ref requested); long p = produced; if (r != p) { produced = p + 1; actual.OnNext(value); } else { Cancel(); actual.OnError(BackpressureHelper.MissingBackpressureException()); } }
/// <inheritDoc/> public void OnNext(T t) { if (done) { return; } if (sourceMode == FuseableHelper.NONE) { if (!queue.Offer(t)) { SubscriptionHelper.Cancel(ref s); OnError(BackpressureHelper.MissingBackpressureException()); return; } } Drain(); }
public void OnNext(T t) { if (done) { return; } if (sourceMode != FuseableHelper.ASYNC) { if (!queue.Offer(t)) { s.Cancel(); OnError(BackpressureHelper.MissingBackpressureException()); return; } } Signal(); }
void Emit(IProcessor <T, T> w) { long r = bp.Requested(); if (r != 0L) { actual.OnNext(w); if (r != long.MaxValue) { bp.Produced(1); } } else { Cancel(); OnError(BackpressureHelper.MissingBackpressureException()); } }
void Emit(IProcessor <T, T> w) { long r = Volatile.Read(ref requested); if (r != 0L) { actual.OnNext(w); if (r != long.MaxValue) { Interlocked.Decrement(ref requested); } } else { Cancel(); actual.OnError(BackpressureHelper.MissingBackpressureException()); } }
void Emit(T value, long index) { if (index == Volatile.Read(ref this.index)) { long r = bp.Requested(); if (r != 0L) { actual.OnNext(value); if (r != long.MaxValue) { bp.Produced(1); } return; } Cancel(); actual.OnError(BackpressureHelper.MissingBackpressureException()); } }
internal void Run() { long c = count; count = c + 1; long r = Volatile.Read(ref requested); if (r != 0L) { actual.OnNext(c); if (r != long.MaxValue) { Interlocked.Decrement(ref requested); } return; } Cancel(); actual.OnError(BackpressureHelper.MissingBackpressureException()); }
public void Next(T value) { if (done) { return; } long r = Volatile.Read(ref requested); long p = produced; if (r != p) { produced = p + 1; actual.OnNext(value); } else { done = true; Cancel(); actual.OnError(BackpressureHelper.MissingBackpressureException()); } }
public void OnNext(T t) { if (done) { return; } long e = produced.Get(); long r = requested.GetVolatile(); if (r != e) { produced.Set(e + 1); actual.OnNext(t); } else { done = true; s.Cancel(); actual.OnError(BackpressureHelper.MissingBackpressureException()); } }
internal void Run() { var v = Interlocked.Exchange(ref value, null); if (v != null) { long r = Volatile.Read(ref requested); if (r != 0L) { actual.OnNext(v.value); if (r != long.MaxValue) { Interlocked.Decrement(ref requested); } } else { Cancel(); actual.OnError(BackpressureHelper.MissingBackpressureException()); } } }
void Drain() { if (!QueueDrainHelper.Enter(ref wip)) { return; } int missed = 1; var q = queue; var a = actual; var buf = buffer; for (;;) { for (;;) { if (Volatile.Read(ref cancelled)) { q.Clear(); return; } Exception ex = Volatile.Read(ref error); if (ex != null) { q.Clear(); a.OnError(ex); return; } BufferWork bw; if (q.Poll(out bw)) { switch (bw.type) { case BufferWorkType.COMPLETE: { Interlocked.Exchange(ref index, long.MaxValue); q.Clear(); buffer = null; if (buf.Count == 0L) { a.OnComplete(); } else { long r = Volatile.Read(ref requested); long p = produced; if (r != p) { a.OnNext(buf); a.OnComplete(); } else { a.OnError(BackpressureHelper.MissingBackpressureException()); } } worker.Dispose(); return; } case BufferWorkType.BOUNDARY: { long idx = Interlocked.Increment(ref index); if (buf.Count != 0) { long r = Volatile.Read(ref requested); long p = produced; if (r != p) { buffer = new List <T>(); a.OnNext(buf); buf = buffer; if (r != long.MaxValue) { produced = p + 1; } Schedule(idx); } else { s.Cancel(); d.Dispose(); worker.Dispose(); q.Clear(); a.OnError(BackpressureHelper.MissingBackpressureException()); return; } } else { Schedule(idx); } } break; default: { buf.Add(bw.value); if (buf.Count == maxSize) { long idx = Interlocked.Increment(ref index); long r = Volatile.Read(ref requested); long p = produced; if (r != p) { buffer = new List <T>(); a.OnNext(buf); buf = buffer; if (r != long.MaxValue) { produced = p + 1; } Schedule(idx); } else { s.Cancel(); d.Dispose(); worker.Dispose(); q.Clear(); a.OnError(BackpressureHelper.MissingBackpressureException()); return; } } } break; } } else { break; } } missed = QueueDrainHelper.Leave(ref wip, missed); if (missed == 0) { break; } } }