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)); } })); }
public PublisherDelaySelector(ISubscriber <T> actual, Func <T, IPublisher <U> > delayFactory) { this.actual.Init(actual); wip = 1; this.delayFactory = delayFactory; this.set = new SetCompositeDisposable(); }
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)); })); }
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>(); }
public MergeCompletableSubscriber(ICompletableSubscriber actual) { this.actual = actual; this.all = new SetCompositeDisposable(); }
internal TaskExecutorWorker() { this.tasks = new SetCompositeDisposable(); }