public void InnerNext(CombineLatestSubscriber sender, int index, T value) { var a = latest; int n = a.Length; int activeCount = Volatile.Read(ref active); if (!sender.hasValue) { sender.hasValue = true; activeCount = Interlocked.Increment(ref active); } bool drain = activeCount == n; lock (this) { a[index] = value; if (drain) { T[] b = new T[n]; Array.Copy(a, 0, b, 0, n); queue.Offer(new Entry(b, sender)); } } if (drain) { Drain(); } else { sender.RequestOne(); } }
void InnerNext(CombineLatestSubscriber sender, T item) { bool drain = false; lock (this) { if (!sender.hasValue) { active++; sender.hasValue = true; } latest[sender.index] = item; int n = subscribers.Length; drain = active == n; if (drain) { Entry e = new Entry(); e.sender = sender; e.items = new T[n]; Array.Copy(latest, 0, e.items, 0, n); queue.Offer(e); } } if (drain) { Drain(); } else { sender.RequestOne(); } }
void InnerComplete(CombineLatestSubscriber sender) { if (!sender.done) { sender.done = true; Interlocked.Increment(ref terminated); Drain(); } }
public void InnerComplete(CombineLatestSubscriber sender) { if (!sender.hasValue) { CancelAll(); Volatile.Write(ref hasEmptySource, true); } Interlocked.Increment(ref complete); Drain(); }
void InnerError(CombineLatestSubscriber sender, Exception cause) { if (!sender.done) { sender.done = true; ExceptionHelper.AddException(ref error, cause); Interlocked.Increment(ref terminated); Drain(); } }
public void InnerError(CombineLatestSubscriber sender, Exception e) { if (ExceptionHelper.AddError(ref error, e)) { InnerComplete(sender); } else { ExceptionHelper.OnErrorDropped(e); } }
internal CombineLatestSubscription(IFlowableSubscriber <R> actual, Func <T[], R> combiner, int n, int prefetch) { this.actual = actual; this.combiner = combiner; latest = new T[n]; var s = new CombineLatestSubscriber[n]; for (int i = 0; i < n; i++) { s[i] = new CombineLatestSubscriber(this, i, prefetch); } this.subscribers = s; this.queue = new SpscLinkedArrayQueue <Entry>(prefetch); }
internal CombineLatestConditionalSubscription(IConditionalSubscriber <R> actual, int prefetch, bool delayError, Func <T[], R> combiner, int n) { this.actual = actual; this.prefetch = prefetch; this.delayError = delayError; this.combiner = combiner; this.latest = new T[n]; var a = new CombineLatestSubscriber[n]; for (int i = 0; i < n; i++) { a[i] = new CombineLatestSubscriber(this, i, prefetch); } this.subscribers = a; this.queue = new SpscLinkedArrayQueue <Entry>(prefetch); }
internal Entry(T[] sourceRow, CombineLatestSubscriber sender) { this.row = sourceRow; this.sender = sender; }