@Test public void requestCancelConditionalRace2() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { final TestSubscriber<Integer> ts = new TestSubscriber<Integer>(0L); Runnable r1 = new Runnable() { @Override public void run() { ts.request(Long.MAX_VALUE); } }; Runnable r2 = new Runnable() { @Override public void run() { ts.cancel(); } }; Flowable.fromIterable(Arrays.asList(1, 2, 3, 4)) .filter(Functions.alwaysTrue()) .subscribe(ts); TestHelper.race(r1, r2); } }
public static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { boolean hasNext; try { hasNext = it.hasNext(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (!hasNext) { EmptySubscription.complete(s); return; } if (s instanceof ConditionalSubscriber) { s.onSubscribe(new IteratorConditionalSubscription<T>( (ConditionalSubscriber<? super T>)s, it)); } else { s.onSubscribe(new IteratorSubscription<T>(s, it)); } }
FlowableFromIterable extends Flowable<T> { public static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { boolean hasNext; try { hasNext = it.hasNext(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (!hasNext) { EmptySubscription.complete(s); return; } if (s instanceof ConditionalSubscriber) { s.onSubscribe(new IteratorConditionalSubscription<T>( (ConditionalSubscriber<? super T>)s, it)); } else { s.onSubscribe(new IteratorSubscription<T>(s, it)); } } }
FlowableFromIterable extends Flowable<T> { public static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { boolean hasNext; try { hasNext = it.hasNext(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (!hasNext) { EmptySubscription.complete(s); return; } if (s instanceof ConditionalSubscriber) { s.onSubscribe(new IteratorConditionalSubscription<T>( (ConditionalSubscriber<? super T>)s, it)); } else { s.onSubscribe(new IteratorSubscription<T>(s, it)); } } FlowableFromIterable(Iterable<? extends T> source); }
FlowableFromIterable extends Flowable<T> { public static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { boolean hasNext; try { hasNext = it.hasNext(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (!hasNext) { EmptySubscription.complete(s); return; } if (s instanceof ConditionalSubscriber) { s.onSubscribe(new IteratorConditionalSubscription<T>( (ConditionalSubscriber<? super T>)s, it)); } else { s.onSubscribe(new IteratorSubscription<T>(s, it)); } } FlowableFromIterable(Iterable<? extends T> source); @Override void subscribeActual(Subscriber<? super T> s); static void subscribe(Subscriber<? super T> s, Iterator<? extends T> it); }
FlowableFromIterable extends Flowable<T> { public static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { boolean hasNext; try { hasNext = it.hasNext(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); return; } if (!hasNext) { EmptySubscription.complete(s); return; } if (s instanceof ConditionalSubscriber) { s.onSubscribe(new IteratorConditionalSubscription<T>( (ConditionalSubscriber<? super T>)s, it)); } else { s.onSubscribe(new IteratorSubscription<T>(s, it)); } } FlowableFromIterable(Iterable<? extends T> source); @Override void subscribeActual(Subscriber<? super T> s); static void subscribe(Subscriber<? super T> s, Iterator<? extends T> it);  }