Example #1
0
        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));
                }
            }));
        }
Example #2
0
 public PublisherDelaySelector(ISubscriber <T> actual, Func <T, IPublisher <U> > delayFactory)
 {
     this.actual.Init(actual);
     wip = 1;
     this.delayFactory = delayFactory;
     this.set          = new SetCompositeDisposable();
 }
Example #3
0
        public static ISingle <bool> Equals <T>(this ISingle <T> first, ISingle <T> second)
        {
            return(Create <bool>(s =>
            {
                T[] array = new T[2];
                int[] counter = { 2 };
                SetCompositeDisposable all = new SetCompositeDisposable();

                s.OnSubscribe(all);

                first.Subscribe(new EqualsSingleSubscriber <T>(s, 0, array, counter, all));
                second.Subscribe(new EqualsSingleSubscriber <T>(s, 1, array, counter, all));
            }));
        }
Example #4
0
        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));
                }
            }));
        }
 public ThreadPoolWorker()
 {
     tasks = new SetCompositeDisposable();
     queue = new ConcurrentQueue <ScheduledAction>();
 }
Example #6
0
 public MergeCompletableSubscriber(ICompletableSubscriber actual)
 {
     this.actual = actual;
     this.all    = new SetCompositeDisposable();
 }
Example #7
0
 internal TaskExecutorWorker()
 {
     this.tasks = new SetCompositeDisposable();
 }