Exemplo n.º 1
0
            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();
                }
            }
Exemplo n.º 2
0
            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();
                }
            }
Exemplo n.º 3
0
 void InnerComplete(CombineLatestSubscriber sender)
 {
     if (!sender.done)
     {
         sender.done = true;
         Interlocked.Increment(ref terminated);
         Drain();
     }
 }
Exemplo n.º 4
0
 public void InnerComplete(CombineLatestSubscriber sender)
 {
     if (!sender.hasValue)
     {
         CancelAll();
         Volatile.Write(ref hasEmptySource, true);
     }
     Interlocked.Increment(ref complete);
     Drain();
 }
Exemplo n.º 5
0
 void InnerError(CombineLatestSubscriber sender, Exception cause)
 {
     if (!sender.done)
     {
         sender.done = true;
         ExceptionHelper.AddException(ref error, cause);
         Interlocked.Increment(ref terminated);
         Drain();
     }
 }
Exemplo n.º 6
0
 public void InnerError(CombineLatestSubscriber sender, Exception e)
 {
     if (ExceptionHelper.AddError(ref error, e))
     {
         InnerComplete(sender);
     }
     else
     {
         ExceptionHelper.OnErrorDropped(e);
     }
 }
Exemplo n.º 7
0
            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);
            }
Exemplo n.º 8
0
            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);
            }
Exemplo n.º 9
0
 internal Entry(T[] sourceRow, CombineLatestSubscriber sender)
 {
     this.row    = sourceRow;
     this.sender = sender;
 }