public void Request(long n) { if (SubscriptionHelper.Validate(n)) { BackpressureHelper.GetAndAddCap(ref requested, n); } }
/// <summary> /// Indicate the number of items produced and subtract it from /// the current requested amount (if not unbounded). /// </summary> /// <param name="n">The produced amount, positive (not verified).</param> public void Produced(long n) { if (Volatile.Read(ref wip) == 0 && Interlocked.CompareExchange(ref wip, 1, 0) == 0) { long r = requested; if (r != long.MaxValue) { r -= n; if (r < 0L) { ExceptionHelper.OnErrorDropped(new InvalidOperationException("More produced than requested: " + r)); r = 0L; } requested = r; } if (Interlocked.Decrement(ref wip) == 0) { return; } } else { BackpressureHelper.GetAndAddCap(ref missedProduced, n); if (Interlocked.Increment(ref wip) != 1) { return; } } Drain(); }
/// <summary> /// Request the specified amount (not validated) from the current ISubscription if present /// or accumulate it until an ISubscription is set. /// </summary> /// <param name="n">The request amount, positive (not validated)</param> public void Request(long n) { if (Volatile.Read(ref wip) == 0 && Interlocked.CompareExchange(ref wip, 1, 0) == 0) { long r = requested; var curr = current; if (r != long.MaxValue) { requested = BackpressureHelper.AddCap(r, n); } if (Interlocked.Decrement(ref wip) != 0) { Drain(); } curr?.Request(n); } else { BackpressureHelper.GetAndAddCap(ref missedRequested, n); if (Interlocked.Increment(ref wip) != 1) { return; } Drain(); } }
public void Request(long n) { if (SubscriptionHelper.Validate(n)) { BackpressureHelper.GetAndAddCap(ref requested, n); parent.buffer.Drain(this); } }
internal void Request(int index, long n) { if (SubscriptionHelper.Validate(n)) { var rs = requests; BackpressureHelper.GetAndAddCap(ref rs[index], n); if (Volatile.Read(ref subscriberCount) == rs.Length) { Drain(); } } }
public void Request(long n) { if (SubscriptionHelper.Validate(n)) { if (BackpressureHelper.GetAndAddCap(ref requested, n) == 0) { if (n == long.MaxValue) { FastPath(); } else { SlowPath(n); } } } }