16
16
17
17
import org .reactivestreams .Publisher ;
18
18
19
- import io .reactivex .annotations .SchedulerSupport ;
19
+ import io .reactivex .annotations .* ;
20
20
import io .reactivex .disposables .Disposable ;
21
21
import io .reactivex .exceptions .Exceptions ;
22
22
import io .reactivex .functions .*;
23
23
import io .reactivex .internal .functions .*;
24
+ import io .reactivex .internal .fuseable .*;
24
25
import io .reactivex .internal .observers .*;
25
26
import io .reactivex .internal .operators .completable .*;
26
27
import io .reactivex .internal .operators .flowable .FlowableDelaySubscriptionOther ;
@@ -43,7 +44,7 @@ public abstract class Completable implements CompletableSource {
43
44
* terminates (normally or with an error) and cancels all other Completables.
44
45
* <dl>
45
46
* <dt><b>Scheduler:</b></dt>
46
- * <dd>{@code amb } does not operate by default on a particular {@link Scheduler}.</dd>
47
+ * <dd>{@code ambArray } does not operate by default on a particular {@link Scheduler}.</dd>
47
48
* </dl>
48
49
* @param sources the array of source Completables
49
50
* @return the new Completable instance
@@ -97,7 +98,7 @@ public static Completable complete() {
97
98
* Returns a Completable which completes only when all sources complete, one after another.
98
99
* <dl>
99
100
* <dt><b>Scheduler:</b></dt>
100
- * <dd>{@code concat } does not operate by default on a particular {@link Scheduler}.</dd>
101
+ * <dd>{@code concatArray } does not operate by default on a particular {@link Scheduler}.</dd>
101
102
* </dl>
102
103
* @param sources the sources to concatenate
103
104
* @return the Completable instance which completes only when all sources complete
@@ -143,6 +144,7 @@ public static Completable concat(Iterable<? extends CompletableSource> sources)
143
144
* @throws NullPointerException if sources is null
144
145
*/
145
146
@ SchedulerSupport (SchedulerSupport .NONE )
147
+ @ BackpressureSupport (BackpressureKind .FULL )
146
148
public static Completable concat (Publisher <? extends CompletableSource > sources ) {
147
149
return concat (sources , 2 );
148
150
}
@@ -159,6 +161,7 @@ public static Completable concat(Publisher<? extends CompletableSource> sources)
159
161
* @throws NullPointerException if sources is null
160
162
*/
161
163
@ SchedulerSupport (SchedulerSupport .NONE )
164
+ @ BackpressureSupport (BackpressureKind .FULL )
162
165
public static Completable concat (Publisher <? extends CompletableSource > sources , int prefetch ) {
163
166
ObjectHelper .requireNonNull (sources , "sources is null" );
164
167
ObjectHelper .verifyPositive (prefetch , "prefetch" );
@@ -359,6 +362,7 @@ public static <T> Completable fromObservable(final ObservableSource<T> observabl
359
362
* @return the new Completable instance
360
363
* @throws NullPointerException if publisher is null
361
364
*/
365
+ @ BackpressureSupport (BackpressureKind .UNBOUNDED_IN )
362
366
@ SchedulerSupport (SchedulerSupport .NONE )
363
367
public static <T > Completable fromPublisher (final Publisher <T > publisher ) {
364
368
ObjectHelper .requireNonNull (publisher , "publisher is null" );
@@ -388,7 +392,7 @@ public static <T> Completable fromSingle(final SingleSource<T> single) {
388
392
* completes only when all source Completables complete or one of them emits an error.
389
393
* <dl>
390
394
* <dt><b>Scheduler:</b></dt>
391
- * <dd>{@code merge } does not operate by default on a particular {@link Scheduler}.</dd>
395
+ * <dd>{@code mergeArray } does not operate by default on a particular {@link Scheduler}.</dd>
392
396
* </dl>
393
397
* @param sources the iterable sequence of sources.
394
398
* @return the new Completable instance
@@ -435,6 +439,7 @@ public static Completable merge(Iterable<? extends CompletableSource> sources) {
435
439
* @throws NullPointerException if sources is null
436
440
*/
437
441
@ SchedulerSupport (SchedulerSupport .NONE )
442
+ @ BackpressureSupport (BackpressureKind .UNBOUNDED_IN )
438
443
public static Completable merge (Publisher <? extends CompletableSource > sources ) {
439
444
return merge0 (sources , Integer .MAX_VALUE , false );
440
445
}
@@ -453,6 +458,7 @@ public static Completable merge(Publisher<? extends CompletableSource> sources)
453
458
* @throws IllegalArgumentException if maxConcurrency is less than 1
454
459
*/
455
460
@ SchedulerSupport (SchedulerSupport .NONE )
461
+ @ BackpressureSupport (BackpressureKind .FULL )
456
462
public static Completable merge (Publisher <? extends CompletableSource > sources , int maxConcurrency ) {
457
463
return merge0 (sources , maxConcurrency , false );
458
464
}
@@ -473,6 +479,7 @@ public static Completable merge(Publisher<? extends CompletableSource> sources,
473
479
* @throws IllegalArgumentException if maxConcurrency is less than 1
474
480
*/
475
481
@ SchedulerSupport (SchedulerSupport .NONE )
482
+ @ BackpressureSupport (BackpressureKind .FULL )
476
483
private static Completable merge0 (Publisher <? extends CompletableSource > sources , int maxConcurrency , boolean delayErrors ) {
477
484
ObjectHelper .requireNonNull (sources , "sources is null" );
478
485
ObjectHelper .verifyPositive (maxConcurrency , "maxConcurrency" );
@@ -485,7 +492,7 @@ private static Completable merge0(Publisher<? extends CompletableSource> sources
485
492
* them terminate in a way or another.
486
493
* <dl>
487
494
* <dt><b>Scheduler:</b></dt>
488
- * <dd>{@code mergeDelayError } does not operate by default on a particular {@link Scheduler}.</dd>
495
+ * <dd>{@code mergeArrayDelayError } does not operate by default on a particular {@link Scheduler}.</dd>
489
496
* </dl>
490
497
* @param sources the array of Completables
491
498
* @return the new Completable instance
@@ -529,6 +536,7 @@ public static Completable mergeDelayError(Iterable<? extends CompletableSource>
529
536
* @throws NullPointerException if sources is null
530
537
*/
531
538
@ SchedulerSupport (SchedulerSupport .NONE )
539
+ @ BackpressureSupport (BackpressureKind .UNBOUNDED_IN )
532
540
public static Completable mergeDelayError (Publisher <? extends CompletableSource > sources ) {
533
541
return merge0 (sources , Integer .MAX_VALUE , true );
534
542
}
@@ -548,6 +556,7 @@ public static Completable mergeDelayError(Publisher<? extends CompletableSource>
548
556
* @throws NullPointerException if sources is null
549
557
*/
550
558
@ SchedulerSupport (SchedulerSupport .NONE )
559
+ @ BackpressureSupport (BackpressureKind .FULL )
551
560
public static Completable mergeDelayError (Publisher <? extends CompletableSource > sources , int maxConcurrency ) {
552
561
return merge0 (sources , maxConcurrency , true );
553
562
}
@@ -670,7 +679,7 @@ public static <R> Completable using(
670
679
* if not already Completable.
671
680
* <dl>
672
681
* <dt><b>Scheduler:</b></dt>
673
- * <dd>{@code amb } does not operate by default on a particular {@link Scheduler}.</dd>
682
+ * <dd>{@code wrap } does not operate by default on a particular {@link Scheduler}.</dd>
674
683
* </dl>
675
684
* @param source the source to wrap
676
685
* @return the source or its wrapper Completable
@@ -736,6 +745,7 @@ public final <T> Observable<T> andThen(ObservableSource<T> next) {
736
745
* @return Flowable that composes this Completable and next
737
746
* @throws NullPointerException if next is null
738
747
*/
748
+ @ BackpressureSupport (BackpressureKind .FULL )
739
749
@ SchedulerSupport (SchedulerSupport .NONE )
740
750
public final <T > Flowable <T > andThen (Publisher <T > next ) {
741
751
ObjectHelper .requireNonNull (next , "next is null" );
@@ -821,7 +831,7 @@ public final boolean blockingAwait(long timeout, TimeUnit unit) {
821
831
* the emitted exception if any.
822
832
* <dl>
823
833
* <dt><b>Scheduler:</b></dt>
824
- * <dd>{@code doAfterTerminate } does not operate by default on a particular {@link Scheduler}.</dd>
834
+ * <dd>{@code blockingGet } does not operate by default on a particular {@link Scheduler}.</dd>
825
835
* </dl>
826
836
* @return the throwable if this terminated with an error, null otherwise
827
837
* @throws RuntimeException that wraps an InterruptedException if the wait is interrupted
@@ -836,6 +846,10 @@ public final Throwable blockingGet() {
836
846
/**
837
847
* Subscribes to this Completable instance and blocks until it terminates or the specified timeout
838
848
* elapses, then returns null for normal termination or the emitted exception if any.
849
+ * <dl>
850
+ * <dt><b>Scheduler:</b></dt>
851
+ * <dd>{@code blockingGet} does not operate by default on a particular {@link Scheduler}.</dd>
852
+ * </dl>
839
853
* @param timeout the timeout value
840
854
* @param unit the time unit
841
855
* @return the throwable if this terminated with an error, null otherwise
@@ -1162,7 +1176,7 @@ public final Completable onErrorComplete() {
1162
1176
* true, it will emit an onComplete and swallow the throwable.
1163
1177
* <dl>
1164
1178
* <dt><b>Scheduler:</b></dt>
1165
- * <dd>{@code doErrorComplete } does not operate by default on a particular {@link Scheduler}.</dd>
1179
+ * <dd>{@code onErrorComplete } does not operate by default on a particular {@link Scheduler}.</dd>
1166
1180
* </dl>
1167
1181
* @param predicate the predicate to call when an Throwable is emitted which should return true
1168
1182
* if the Throwable should be swallowed and replaced with an onComplete.
@@ -1381,6 +1395,7 @@ public final <T> Observable<T> startWith(Observable<T> other) {
1381
1395
* @return the new Observable instance
1382
1396
* @throws NullPointerException if other is null
1383
1397
*/
1398
+ @ BackpressureSupport (BackpressureKind .FULL )
1384
1399
@ SchedulerSupport (SchedulerSupport .NONE )
1385
1400
public final <T > Flowable <T > startWith (Publisher <T > other ) {
1386
1401
ObjectHelper .requireNonNull (other , "other is null" );
@@ -1442,12 +1457,17 @@ public final void subscribe(CompletableObserver s) {
1442
1457
*
1443
1458
* composite.add(source.subscribeWith(new ResourceCompletableObserver()));
1444
1459
* </code></pre>
1460
+ * <dl>
1461
+ * <dt><b>Scheduler:</b></dt>
1462
+ * <dd>{@code subscribeWith} does not operate by default on a particular {@link Scheduler}.</dd>
1463
+ * </dl>
1445
1464
* @param <E> the type of the CompletableObserver to use and return
1446
1465
* @param observer the CompletableObserver (subclass) to use and return, not null
1447
1466
* @return the input {@code observer}
1448
1467
* @throws NullPointerException if {@code observer} is null
1449
1468
* @since 2.0
1450
1469
*/
1470
+ @ SchedulerSupport (SchedulerSupport .NONE )
1451
1471
public final <E extends CompletableObserver > E subscribeWith (E observer ) {
1452
1472
subscribe (observer );
1453
1473
return observer ;
@@ -1595,6 +1615,10 @@ public final Completable timeout(long timeout, TimeUnit unit, Scheduler schedule
1595
1615
* Returns a Completable that runs this Completable and optionally switches to the other Completable
1596
1616
* in case this Completable doesn't complete within the given time while "waiting" on
1597
1617
* the specified scheduler.
1618
+ * <dl>
1619
+ * <dt><b>Scheduler:</b></dt>
1620
+ * <dd>you specify the {@link Scheduler} this operator runs on.</dd>
1621
+ * </dl>
1598
1622
* @param timeout the timeout value
1599
1623
* @param unit the timeout unit
1600
1624
* @param scheduler the scheduler to use to wait for completion
@@ -1641,8 +1665,13 @@ public final <U> U to(Function<? super Completable, U> converter) {
1641
1665
* @param <T> the value type
1642
1666
* @return the new Observable created
1643
1667
*/
1668
+ @ SuppressWarnings ("unchecked" )
1669
+ @ BackpressureSupport (BackpressureKind .FULL )
1644
1670
@ SchedulerSupport (SchedulerSupport .NONE )
1645
1671
public final <T > Flowable <T > toFlowable () {
1672
+ if (this instanceof FuseToFlowable ) {
1673
+ return ((FuseToFlowable <T >)this ).fuseToFlowable ();
1674
+ }
1646
1675
return RxJavaPlugins .onAssembly (new CompletableToFlowable <T >(this ));
1647
1676
}
1648
1677
@@ -1652,13 +1681,18 @@ public final <T> Flowable<T> toFlowable() {
1652
1681
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Single.toObservable.png" alt="">
1653
1682
* <dl>
1654
1683
* <dt><b>Scheduler:</b></dt>
1655
- * <dd>{@code toCompletable } does not operate by default on a particular {@link Scheduler}.</dd>
1684
+ * <dd>{@code toMaybe } does not operate by default on a particular {@link Scheduler}.</dd>
1656
1685
* </dl>
1657
1686
*
1658
1687
* @param <T> the value type
1659
1688
* @return an {@link Maybe} that emits a single item T or an error.
1660
1689
*/
1690
+ @ SuppressWarnings ("unchecked" )
1691
+ @ SchedulerSupport (SchedulerSupport .NONE )
1661
1692
public final <T > Maybe <T > toMaybe () {
1693
+ if (this instanceof FuseToMaybe ) {
1694
+ return ((FuseToMaybe <T >)this ).fuseToMaybe ();
1695
+ }
1662
1696
return RxJavaPlugins .onAssembly (new MaybeFromCompletable <T >(this ));
1663
1697
}
1664
1698
@@ -1672,8 +1706,12 @@ public final <T> Maybe<T> toMaybe() {
1672
1706
* @param <T> the value type
1673
1707
* @return the new Observable created
1674
1708
*/
1709
+ @ SuppressWarnings ("unchecked" )
1675
1710
@ SchedulerSupport (SchedulerSupport .NONE )
1676
1711
public final <T > Observable <T > toObservable () {
1712
+ if (this instanceof FuseToObservable ) {
1713
+ return ((FuseToObservable <T >)this ).fuseToObservable ();
1714
+ }
1677
1715
return RxJavaPlugins .onAssembly (new CompletableToObservable <T >(this ));
1678
1716
}
1679
1717
@@ -1736,9 +1774,14 @@ public final Completable unsubscribeOn(final Scheduler scheduler) {
1736
1774
/**
1737
1775
* Creates a TestSubscriber and subscribes
1738
1776
* it to this Completable.
1777
+ * <dl>
1778
+ * <dt><b>Scheduler:</b></dt>
1779
+ * <dd>{@code test} does not operate by default on a particular {@link Scheduler}.</dd>
1780
+ * </dl>
1739
1781
* @return the new TestSubscriber instance
1740
1782
* @since 2.0
1741
1783
*/
1784
+ @ SchedulerSupport (SchedulerSupport .NONE )
1742
1785
public final TestSubscriber <Void > test () {
1743
1786
TestSubscriber <Void > ts = new TestSubscriber <Void >();
1744
1787
subscribe (new SubscriberCompletableObserver <Void >(ts ));
@@ -1749,9 +1792,14 @@ public final TestSubscriber<Void> test() {
1749
1792
* Creates a TestSubscriber optionally in cancelled state, then subscribes it to this Completable.
1750
1793
* @param cancelled if true, the TestSubscriber will be cancelled before subscribing to this
1751
1794
* Completable.
1795
+ * <dl>
1796
+ * <dt><b>Scheduler:</b></dt>
1797
+ * <dd>{@code test} does not operate by default on a particular {@link Scheduler}.</dd>
1798
+ * </dl>
1752
1799
* @return the new TestSubscriber instance
1753
1800
* @since 2.0
1754
1801
*/
1802
+ @ SchedulerSupport (SchedulerSupport .NONE )
1755
1803
public final TestSubscriber <Void > test (boolean cancelled ) {
1756
1804
TestSubscriber <Void > ts = new TestSubscriber <Void >();
1757
1805
0 commit comments