public void Cancel() { if (!Volatile.Read(ref cancelled)) { Volatile.Write(ref cancelled, true); upstream.Cancel(); worker.Dispose(); if (!outputMode && Interlocked.Increment(ref wip) == 1) { queue.Clear(); } } }
public void Cancel() { Volatile.Write(ref cancelled, true); DisposableHelper.Dispose(ref upstream); if (Interlocked.Increment(ref wip) == 1) { queue.Clear(); } }
internal static void QueueDrainFused <T>(IFlowableSubscriber <T> a, ref int wip, ISimpleQueue <T> q, ref bool cancelled, ref bool done, ref Exception error) { if (Interlocked.Increment(ref wip) != 1) { return; } int missed = 1; for (;;) { if (Volatile.Read(ref cancelled)) { q.Clear(); return; } bool d = Volatile.Read(ref done); bool empty = q.IsEmpty(); if (!empty) { a.OnNext(default(T)); } if (d) { var ex = error; if (ex == null) { a.OnComplete(); } else { a.OnError(ex); } } int w = Volatile.Read(ref wip); if (w == missed) { missed = Interlocked.Add(ref wip, -missed); if (missed == 0) { break; } } else { missed = w; } } }
void DrainFused() { int missed = 1; IFlowableSubscriber <T> a = actual; ISimpleQueue <T> q = queue; for (;;) { if (Volatile.Read(ref cancelled)) { q.Clear(); return; } bool d = Volatile.Read(ref done); bool empty = q.IsEmpty(); if (!empty) { a.OnNext(default(T)); } if (d) { Exception ex = error; if (ex != null) { a.OnError(ex); } else { a.OnComplete(); } return; } int w = Volatile.Read(ref wip); if (w == missed) { missed = Interlocked.Add(ref wip, -missed); if (missed == 0) { break; } } else { missed = w; } } }
public void Clear() { queue.Clear(); }
public void Clear() { queue.Clear(); accumulator = default(R); }
public void Clear() { windows.Clear(); }
public void Clear() { queue.Clear(); DisposeSilently(current); current = null; }
void DrainAsync() { int missed = 1; long e = emitted; int f = consumed; int lim = limit; IFlowableSubscriber <T> a = actual; ISimpleQueue <T> q = queue; for (;;) { long r = Volatile.Read(ref requested); while (e != r) { if (Volatile.Read(ref cancelled)) { q.Clear(); return; } bool d = Volatile.Read(ref done); bool empty = !q.Poll(out T item); if (d && empty) { Exception ex = error; if (ex != null) { a.OnError(ex); } else { a.OnComplete(); } return; } if (empty) { break; } a.OnNext(item); e++; if (++f == lim) { f = 0; upstream.Request(lim); } } if (e == r) { if (Volatile.Read(ref cancelled)) { q.Clear(); return; } bool d = Volatile.Read(ref done); bool empty = q.IsEmpty(); if (d && empty) { Exception ex = error; if (ex != null) { a.OnError(ex); } else { a.OnComplete(); } return; } } int w = Volatile.Read(ref wip); if (w == missed) { emitted = e; consumed = f; missed = Interlocked.Add(ref wip, -missed); if (missed == 0) { break; } } else { missed = w; } } }
internal static void QueueDrain <T>(IFlowableSubscriber <T> a, ref int wip, ISimpleQueue <T> q, ref long requested, ref long emitted, ref bool cancelled, ref bool done, ref Exception error) { if (Interlocked.Increment(ref wip) != 1) { return; } int missed = 1; var e = emitted; for (;;) { long r = Volatile.Read(ref requested); while (e != r) { if (Volatile.Read(ref cancelled)) { q.Clear(); return; } bool d = Volatile.Read(ref done); bool empty = !q.Poll(out var item); if (d && empty) { var ex = error; if (ex == null) { a.OnComplete(); } else { a.OnError(ex); } return; } if (empty) { break; } a.OnNext(item); e++; } if (e == r) { if (Volatile.Read(ref cancelled)) { q.Clear(); return; } bool d = Volatile.Read(ref done); bool empty = q.IsEmpty(); if (d && empty) { var ex = error; if (ex == null) { a.OnComplete(); } else { a.OnError(ex); } return; } } int w = Volatile.Read(ref wip); if (w == missed) { emitted = e; missed = Interlocked.Add(ref wip, -missed); if (missed == 0) { break; } } else { missed = w; } } }