コード例 #1
0
                public void Run()
                {
                    int missed = 1;

                    for (;;)
                    {
                        for (;;)
                        {
                            if (tasks.IsDisposed())
                            {
                                return;
                            }

                            ScheduledAction sa;

                            if (!queue.TryDequeue(out sa))
                            {
                                break;
                            }

                            sa.Run();
                        }

                        missed = Interlocked.Add(ref wip, -missed);
                        if (missed == 0)
                        {
                            break;
                        }
                    }
                }
コード例 #2
0
ファイル: Single.cs プロジェクト: lanicon/RxAdvancedFlow
        public static ISingle <R> Zip <T, R>(this ISingle <T>[] sources, Func <T[], R> zipper)
        {
            if (sources.Length == 0)
            {
                return(Throw <R>(() => NoSuchElementException()));
            }
            return(Create <R>(s =>
            {
                int n = sources.Length;

                T[] array = new T[n];
                int[] counter = { n };

                SetCompositeDisposable all = new SetCompositeDisposable();

                s.OnSubscribe(all);

                for (int i = 0; i < n; i++)
                {
                    if (all.IsDisposed())
                    {
                        return;
                    }

                    sources[i].Subscribe(new ZipSingleSubscriber <T, R>(s, i, array, counter, all, zipper));
                }
            }));
        }
コード例 #3
0
ファイル: Single.cs プロジェクト: lanicon/RxAdvancedFlow
        public static ISingle <R> Zip <T, R>(this IEnumerable <ISingle <T> > sources, Func <T[], R> zipper)
        {
            return(Create <R>(s =>
            {
                int n = 0;

                ISingle <T>[] a = new ISingle <T> [8];

                foreach (ISingle <T> source in sources)
                {
                    if (n == a.Length)
                    {
                        ISingle <T>[] b = new ISingle <T> [n + (n >> 2)];
                        Array.Copy(a, 0, b, 0, n);
                        a = b;
                    }
                    a[n++] = source;
                }

                if (n == 0)
                {
                    EmptyDisposable.Error(s, NoSuchElementException());
                    return;
                }

                T[] array = new T[n];
                int[] counter = { n };

                SetCompositeDisposable all = new SetCompositeDisposable();

                s.OnSubscribe(all);

                for (int i = 0; i < n; i++)
                {
                    if (all.IsDisposed())
                    {
                        return;
                    }

                    a[i].Subscribe(new ZipSingleSubscriber <T, R>(s, i, array, counter, all, zipper));
                }
            }));
        }
コード例 #4
0
 public bool IsDisposed()
 {
     return(all.IsDisposed());
 }