public void OnNext(T item) { var idx = index; var w = window; if (index == 0 && Volatile.Read(ref once) == 0) { w = new MonocastSubject <T>(size, onTerminate); window = w; Interlocked.Increment(ref active); downstream.OnNext(w); } w?.OnNext(item); if (++idx == size) { w?.OnCompleted(); window = null; index = 0; } else { index = idx; } }
public void OnNext(T item) { var idx = index; if (idx == 0 && Volatile.Read(ref once) == 0) { var w = new MonocastSubject <T>(size, onTerminate); windows.Enqueue(w); Interlocked.Increment(ref active); downstream.OnNext(w); } foreach (var w in windows) { w.OnNext(item); } int c = count + 1; if (c == size) { windows.Dequeue().OnCompleted(); count = c - skip; } else { count = c; } if (++idx == skip) { index = 0; } else { index = idx; } }
public Group(K key, GroupByObserver parent) { this.key = key; this.parent = parent; this.subject = new MonocastSubject <V>(onTerminate: () => parent.GroupDone(key)); }
public void OnError(Exception ex) { window?.OnError(ex); window = null; downstream.OnError(ex); }
public void OnCompleted() { window?.OnCompleted(); window = null; downstream.OnCompleted(); }
public MonocastDisposable(ISignalObserver <T> downstream, MonocastSubject <T> parent) { this.parent = parent; Volatile.Write(ref this.downstream, downstream); }