Beispiel #1
0
            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;
                }
            }
Beispiel #2
0
            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;
                }
            }
Beispiel #3
0
 public Group(K key, GroupByObserver parent)
 {
     this.key     = key;
     this.parent  = parent;
     this.subject = new MonocastSubject <V>(onTerminate: () => parent.GroupDone(key));
 }
Beispiel #4
0
 public void OnError(Exception ex)
 {
     window?.OnError(ex);
     window = null;
     downstream.OnError(ex);
 }
Beispiel #5
0
 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);
 }