Esempio n. 1
0
 public void Request(long n)
 {
     if (OnSubscribeHelper.ValidateRequest(n))
     {
         BackpressureHelper.Add(ref requested, n);
     }
 }
            public void Request(long n)
            {
                if (OnSubscribeHelper.ValidateRequest(n))
                {
                    ISubscription a = Volatile.Read(ref secondSubscription);

                    if (a == null)
                    {
                        BackpressureHelper.Add(ref requested, n);

                        a = Volatile.Read(ref secondSubscription);

                        if (a != null)
                        {
                            long r = Interlocked.Exchange(ref requested, 0);

                            if (r != 0)
                            {
                                a.Request(r);
                            }
                        }
                    }
                    else
                    {
                        a.Request(n);
                    }
                }
            }
Esempio n. 3
0
            public void Request(long n)
            {
                if (OnSubscribeHelper.ValidateRequest(n))
                {
                    BackpressureHelper.Add(ref requested, n);

                    var m = Volatile.Read(ref parent);
                    if (m != null)
                    {
                        m.Drain();
                    }
                }
            }
 public void Request(long n)
 {
     if (OnSubscribeHelper.ValidateRequest(n))
     {
         if (BackpressureHelper.Add(ref requested, n) == 0)
         {
             if (n == long.MaxValue)
             {
                 FastPath();
             }
             else
             {
                 SlowPath(n);
             }
         }
     }
 }
Esempio n. 5
0
 public void Request(long n)
 {
     if (OnSubscribeHelper.ValidateRequest(n))
     {
         if (BackpressureHelper.Add(ref requested, n) == 0)
         {
             long idx = index;
             if (n >= idx)
             {
                 FastPath(idx);
             }
             else
             {
                 SlowPath(idx, n);
             }
         }
     }
 }
        public void Produced(long n)
        {
            if (Volatile.Read(ref cancelled))
            {
                return;
            }

            if (Volatile.Read(ref wip) == 0)
            {
                int j = Interlocked.CompareExchange(ref wip, 1, 0);

                if (j == 0)
                {
                    long r = requested;

                    if (r != long.MaxValue)
                    {
                        long u = r - n;
                        if (u < 0)
                        {
                            ReportMoreProduced(u);
                            u = 0;
                        }

                        requested = u;
                    }

                    if (Interlocked.Decrement(ref wip) == 0)
                    {
                        return;
                    }
                }
            }

            BackpressureHelper.Add(ref missedProduced, n);

            if (Interlocked.Increment(ref wip) == 1)
            {
                Drain();
            }
        }
        /// <summary>
        /// Request from the current actual ISubscriber (validated).
        /// </summary>
        /// <param name="n">The request amount. Validated</param>
        public void Request(long n)
        {
            if (Volatile.Read(ref cancelled))
            {
                return;
            }

            if (OnSubscribeHelper.ValidateRequest(n))
            {

                if (Volatile.Read(ref wip) == 0)
                {
                    int j = Interlocked.CompareExchange(ref wip, 1, 0);

                    if (j == 0)
                    {

                        requested = BackpressureHelper.AddCap(requested, n);

                        actual?.Request(n);

                        if (Interlocked.Decrement(ref wip) == 0)
                        {
                            return;
                        }
                    }
                }

                BackpressureHelper.Add(ref missedRequested, n);
                    
                if (Interlocked.Increment(ref wip) == 1)
                {
                    Drain();
                }
            }
        }