Beispiel #1
0
            public void OnSubscribe(ISubscription subscription)
            {
                if (SubscriptionHelper.Validate(ref upstream, subscription))
                {
                    OnSubscribe();

                    subscription.Request(bufferSize);
                }
            }
            public void OnSubscribe(ISubscription subscription)
            {
                if (SubscriptionHelper.Validate(ref upstream, subscription))
                {
                    OnStart();

                    subscription.Request(long.MaxValue);
                }
            }
 public void Cancel()
 {
     Volatile.Write(ref cancelled, true);
     SubscriptionHelper.Cancel(ref upstream);
     boundary.Cancel();
     lock (this)
     {
         buffer = default(C);
     }
 }
Beispiel #4
0
                internal void CompleteLast(T entry)
                {
                    long p = produced;

                    if (p != 0L)
                    {
                        SubscriptionHelper.Produced(ref requested, p);
                    }
                    SubscriptionHelper.PostCompleteSingleResult(parent.actual, ref requested, ref last, entry, ref cancelled);
                }
            public void OnError(Exception cause)
            {
                long p = produced;

                if (p != 0L)
                {
                    SubscriptionHelper.Produced(ref requested, p);
                }
                SubscriptionHelper.PostCompleteSingleResult(actual, ref requested, ref fallback, fallback, ref cancelled);
            }
 public void Request(long n)
 {
     if (SubscriptionHelper.Validate(n))
     {
         if (SubscriptionHelper.AddRequest(ref requested, n) == 0)
         {
             OnRequest(n);
         }
     }
 }
Beispiel #7
0
 public void Request(long n)
 {
     if (SubscriptionHelper.Validate(n))
     {
         SubscriptionHelper.AddRequest(ref requested, n);
         if (Volatile.Read(ref done) == 0)
         {
             Drain();
         }
     }
 }
 public void OnComplete()
 {
     if (hasValue)
     {
         actual.OnComplete();
     }
     else
     {
         SubscriptionHelper.PostCompleteSingleResult(actual, ref requested, ref defaultItem, defaultItem, ref cancelled);
     }
 }
 public void Request(long n)
 {
     if (n <= 0L)
     {
         throw new ArgumentOutOfRangeException(nameof(n));
     }
     if (SubscriptionHelper.AddRequest(ref requested, n) == 0)
     {
         OnRequest(n);
     }
 }
 void Request(int index, long n)
 {
     if (SubscriptionHelper.Validate(n))
     {
         SubscriptionHelper.AddRequest(ref subscribers[index].requested, n);
     }
     if (Volatile.Read(ref initDone))
     {
         Drain();
     }
 }
Beispiel #11
0
 public void OnComplete()
 {
     if (done)
     {
         return;
     }
     done = true;
     SubscriptionHelper.Cancel(ref otherSubscriber.upstream);
     latest = null;
     SerializationHelper.OnComplete(actual, ref wip, ref error);
 }
Beispiel #12
0
 public void OnError(Exception cause)
 {
     if (done)
     {
         return;
     }
     done = true;
     SubscriptionHelper.Cancel(ref otherSubscriber.upstream);
     latest = null;
     SerializationHelper.OnError(actual, ref wip, ref error, cause);
 }
 void BoundaryError(Exception cause)
 {
     SubscriptionHelper.Cancel(ref upstream);
     lock (this)
     {
         buffer = default(C);
         error  = cause;
     }
     Volatile.Write(ref done, true);
     Drain();
 }
Beispiel #14
0
 void Drain()
 {
     if (outputFused)
     {
         SubscriptionHelper.QueueDrainFused(actual, ref wip, queue, ref cancelled, ref done, ref error);
     }
     else
     {
         SubscriptionHelper.QueueDrain(actual, ref wip, queue, ref requested, ref emitted, ref cancelled, ref done, ref error);
     }
 }
            public void Request(long n)
            {
                if (n <= 0L)
                {
                    throw new ArgumentOutOfRangeException(nameof(n));
                }
                if (SubscriptionHelper.AddRequest(ref requested, n) == 0)
                {
                    int  idx = index;
                    int  f   = end;
                    long e   = 0;
                    IConditionalSubscriber <int> a = actual;

                    for (;;)
                    {
                        while (idx != f && e != n)
                        {
                            if (Volatile.Read(ref cancelled))
                            {
                                return;
                            }

                            if (a.TryOnNext(idx))
                            {
                                e++;
                            }

                            idx++;
                        }

                        if (idx == f)
                        {
                            if (!Volatile.Read(ref cancelled))
                            {
                                a.OnComplete();
                            }
                            return;
                        }

                        n = Volatile.Read(ref requested);
                        if (e == n)
                        {
                            index = idx;
                            n     = Interlocked.Add(ref requested, -n);
                            if (n == 0L)
                            {
                                break;
                            }
                            e = 0L;
                        }
                    }
                }
            }
 public void Request(long n)
 {
     if (n <= 0L)
     {
         upstream.Cancel();
         OnError(new ArgumentException("§3.9 violated: non-positive request received"));
     }
     else
     {
         SubscriptionHelper.DeferredRequest(ref upstream, ref requested, n);
     }
 }
 public void OnSubscribe(ISubscription subscription)
 {
     if (Interlocked.CompareExchange(ref hasSubscribed, 1, 0) == 0)
     {
         actual.OnSubscribe(this);
         SubscriptionHelper.DeferredSetOnce(ref upstream, ref requested, subscription);
     }
     else
     {
         subscription.Cancel();
     }
 }
Beispiel #18
0
            public void OnSubscribe(ISubscription subscription)
            {
                if (SubscriptionHelper.Validate(ref upstream, subscription))
                {
                    actual.OnSubscribe(this);

                    var b = bufferSize - 1;
                    if (b != 0)
                    {
                        subscription.Request(b);
                    }
                }
            }
 public void OnComplete()
 {
     Volatile.Write(ref done, true);
     if (outputFused)
     {
         actual.OnNext(default(T));
         actual.OnComplete();
     }
     else
     {
         SubscriptionHelper.PostCompleteMultiResult(actual, ref requested, queue, ref cancelled);
     }
 }
            public void Cancel()
            {
                SubscriptionHelper.Cancel(ref upstream);
                foreach (var inner in others)
                {
                    SubscriptionHelper.Cancel(ref inner.upstream);
                }
                var ls = latest;

                for (int i = 0; i < ls.Length; i++)
                {
                    ls[i] = null;
                }
            }
Beispiel #21
0
            public void OnSubscribe(ISubscription subscription)
            {
                if (SubscriptionHelper.Validate(ref upstream, subscription))
                {
                    SequentialDisposable sd = new SequentialDisposable();
                    timer = sd;

                    ArbiterSet(subscription);

                    actual.OnSubscribe(this);

                    sd.Set(worker.Schedule(() => Timeout(0), firstTimeout));
                }
            }
 public void Request(long n)
 {
     if (SubscriptionHelper.Validate(n))
     {
         long u = SubscriptionHelper.MultiplyCap(n, skip);
         if (Volatile.Read(ref firstRequest) == 0 && Interlocked.CompareExchange(ref firstRequest, 1, 0) == 0)
         {
             if (u != long.MaxValue)
             {
                 u -= (skip - size);
             }
         }
         upstream.Request(u);
     }
 }
            void OtherError(Exception ex, int index)
            {
                SubscriptionHelper.Cancel(ref upstream);
                var os = others;
                var n  = os.Length;

                for (int i = 0; i < n; i++)
                {
                    if (i != index)
                    {
                        SubscriptionHelper.Cancel(ref os[i].upstream);
                    }
                }
                SerializationHelper.OnError(actual, ref wip, ref error, ex);
            }
 public void Request(long n)
 {
     if (SubscriptionHelper.Validate(n))
     {
         SubscriptionHelper.AddRequest(ref requested, n);
         if (outputFused)
         {
             DrainFused();
         }
         else
         {
             Drain();
         }
     }
 }
 public void Request(long n)
 {
     if (!SubscriptionHelper.PostCompleteMultiRequest(actual, ref requested, queue, n, ref cancelled))
     {
         long u = SubscriptionHelper.MultiplyCap(n, size - skip);
         if (Volatile.Read(ref firstRequest) == 0 && Interlocked.CompareExchange(ref firstRequest, 1, 0) == 0)
         {
             u += skip;
             if (u < 0L)
             {
                 u = long.MaxValue;
             }
         }
         upstream.Request(u);
     }
 }
 void BoundaryComplete()
 {
     SubscriptionHelper.Cancel(ref upstream);
     lock (this)
     {
         var b = buffer;
         if (b == null)
         {
             return;
         }
         buffer = default(C);
         queue.Offer(b);
     }
     Volatile.Write(ref done, true);
     Drain();
 }
 public void OnComplete()
 {
     if (done)
     {
         return;
     }
     done = true;
     foreach (var inner in others)
     {
         SubscriptionHelper.Cancel(ref inner.upstream);
     }
     for (int i = 0; i < latest.Length; i++)
     {
         latest[i] = null;
     }
     SerializationHelper.OnComplete(actual, ref wip, ref error);
 }
 public void Request(long n)
 {
     if (SubscriptionHelper.Validate(n))
     {
         SubscriptionHelper.AddRequest(ref requested, n);
         long u = SubscriptionHelper.MultiplyCap(n, size - skip);
         if (Volatile.Read(ref firstRequest) == 0 && Interlocked.CompareExchange(ref firstRequest, 1, 0) == 0)
         {
             u += skip;
             if (u < 0L)
             {
                 u = long.MaxValue;
             }
         }
         upstream.Request(u);
     }
 }
 void OtherComplete(int index)
 {
     if (Volatile.Read(ref latest[index]) == null)
     {
         SubscriptionHelper.Cancel(ref upstream);
         var os = others;
         var n  = os.Length;
         for (int i = 0; i < n; i++)
         {
             if (i != index)
             {
                 SubscriptionHelper.Cancel(ref os[i].upstream);
             }
         }
         SerializationHelper.OnComplete(actual, ref wip, ref error);
     }
 }
Beispiel #30
0
 public void OnSubscribe(ISubscription subscription)
 {
     if (requestOn)
     {
         if (SubscriptionHelper.SetOnce(ref upstream, subscription))
         {
             long r = Interlocked.Exchange(ref requested, 0L);
             if (r != 0L)
             {
                 worker.Schedule(() => upstream.Request(r));
             }
         }
     }
     else
     {
         SubscriptionHelper.DeferredSetOnce(ref upstream, ref requested, subscription);
     }
 }