|
12 | 12 | */
|
13 | 13 | package rx;
|
14 | 14 |
|
15 |
| -import java.util.*; |
16 |
| -import java.util.concurrent.*; |
17 |
| - |
18 |
| -import rx.exceptions.*; |
19 |
| -import rx.functions.*; |
20 |
| -import rx.internal.operators.*; |
| 15 | +import java.util.ArrayList; |
| 16 | +import java.util.Arrays; |
| 17 | +import java.util.Collection; |
| 18 | +import java.util.Collections; |
| 19 | +import java.util.List; |
| 20 | +import java.util.Map; |
| 21 | +import java.util.NoSuchElementException; |
| 22 | +import java.util.concurrent.Future; |
| 23 | +import java.util.concurrent.TimeUnit; |
| 24 | + |
| 25 | +import rx.exceptions.Exceptions; |
| 26 | +import rx.exceptions.OnErrorNotImplementedException; |
| 27 | +import rx.functions.Action0; |
| 28 | +import rx.functions.Action1; |
| 29 | +import rx.functions.Action2; |
| 30 | +import rx.functions.Func0; |
| 31 | +import rx.functions.Func1; |
| 32 | +import rx.functions.Func2; |
| 33 | +import rx.functions.Func3; |
| 34 | +import rx.functions.Func4; |
| 35 | +import rx.functions.Func5; |
| 36 | +import rx.functions.Func6; |
| 37 | +import rx.functions.Func7; |
| 38 | +import rx.functions.Func8; |
| 39 | +import rx.functions.Func9; |
| 40 | +import rx.functions.FuncN; |
| 41 | +import rx.functions.Functions; |
| 42 | +import rx.internal.operators.OnSubscribeAmb; |
| 43 | +import rx.internal.operators.OnSubscribeCache; |
| 44 | +import rx.internal.operators.OnSubscribeCombineLatest; |
| 45 | +import rx.internal.operators.OnSubscribeDefer; |
| 46 | +import rx.internal.operators.OnSubscribeDelaySubscription; |
| 47 | +import rx.internal.operators.OnSubscribeDelaySubscriptionWithSelector; |
| 48 | +import rx.internal.operators.OnSubscribeFromIterable; |
| 49 | +import rx.internal.operators.OnSubscribeGroupJoin; |
| 50 | +import rx.internal.operators.OnSubscribeJoin; |
| 51 | +import rx.internal.operators.OnSubscribeMulticastSelector; |
| 52 | +import rx.internal.operators.OnSubscribeRange; |
| 53 | +import rx.internal.operators.OnSubscribeRedo; |
| 54 | +import rx.internal.operators.OnSubscribeTimerOnce; |
| 55 | +import rx.internal.operators.OnSubscribeTimerPeriodically; |
| 56 | +import rx.internal.operators.OnSubscribeToObservableFuture; |
| 57 | +import rx.internal.operators.OnSubscribeUsing; |
| 58 | +import rx.internal.operators.OperatorAll; |
| 59 | +import rx.internal.operators.OperatorAny; |
| 60 | +import rx.internal.operators.OperatorAsObservable; |
| 61 | +import rx.internal.operators.OperatorBufferWithSingleObservable; |
| 62 | +import rx.internal.operators.OperatorBufferWithSize; |
| 63 | +import rx.internal.operators.OperatorBufferWithStartEndObservable; |
| 64 | +import rx.internal.operators.OperatorBufferWithTime; |
| 65 | +import rx.internal.operators.OperatorCast; |
| 66 | +import rx.internal.operators.OperatorConcat; |
| 67 | +import rx.internal.operators.OperatorDebounceWithSelector; |
| 68 | +import rx.internal.operators.OperatorDebounceWithTime; |
| 69 | +import rx.internal.operators.OperatorDefaultIfEmpty; |
| 70 | +import rx.internal.operators.OperatorDelay; |
| 71 | +import rx.internal.operators.OperatorDelayWithSelector; |
| 72 | +import rx.internal.operators.OperatorDematerialize; |
| 73 | +import rx.internal.operators.OperatorDistinct; |
| 74 | +import rx.internal.operators.OperatorDistinctUntilChanged; |
| 75 | +import rx.internal.operators.OperatorDoOnEach; |
| 76 | +import rx.internal.operators.OperatorDoOnSubscribe; |
| 77 | +import rx.internal.operators.OperatorDoOnUnsubscribe; |
| 78 | +import rx.internal.operators.OperatorElementAt; |
| 79 | +import rx.internal.operators.OperatorFilter; |
| 80 | +import rx.internal.operators.OperatorFinally; |
| 81 | +import rx.internal.operators.OperatorGroupBy; |
| 82 | +import rx.internal.operators.OperatorMap; |
| 83 | +import rx.internal.operators.OperatorMapNotification; |
| 84 | +import rx.internal.operators.OperatorMapPair; |
| 85 | +import rx.internal.operators.OperatorMaterialize; |
| 86 | +import rx.internal.operators.OperatorMerge; |
| 87 | +import rx.internal.operators.OperatorMergeDelayError; |
| 88 | +import rx.internal.operators.OperatorMergeMaxConcurrent; |
| 89 | +import rx.internal.operators.OperatorMulticast; |
| 90 | +import rx.internal.operators.OperatorObserveOn; |
| 91 | +import rx.internal.operators.OperatorOnBackpressureBlock; |
| 92 | +import rx.internal.operators.OperatorOnBackpressureBuffer; |
| 93 | +import rx.internal.operators.OperatorOnBackpressureDrop; |
| 94 | +import rx.internal.operators.OperatorOnErrorResumeNextViaFunction; |
| 95 | +import rx.internal.operators.OperatorOnErrorResumeNextViaObservable; |
| 96 | +import rx.internal.operators.OperatorOnErrorReturn; |
| 97 | +import rx.internal.operators.OperatorOnExceptionResumeNextViaObservable; |
| 98 | +import rx.internal.operators.OperatorPublish; |
| 99 | +import rx.internal.operators.OperatorReplay; |
| 100 | +import rx.internal.operators.OperatorRetryWithPredicate; |
| 101 | +import rx.internal.operators.OperatorSampleWithObservable; |
| 102 | +import rx.internal.operators.OperatorSampleWithTime; |
| 103 | +import rx.internal.operators.OperatorScan; |
| 104 | +import rx.internal.operators.OperatorSequenceEqual; |
| 105 | +import rx.internal.operators.OperatorSerialize; |
| 106 | +import rx.internal.operators.OperatorSingle; |
| 107 | +import rx.internal.operators.OperatorSkip; |
| 108 | +import rx.internal.operators.OperatorSkipLast; |
| 109 | +import rx.internal.operators.OperatorSkipLastTimed; |
| 110 | +import rx.internal.operators.OperatorSkipTimed; |
| 111 | +import rx.internal.operators.OperatorSkipUntil; |
| 112 | +import rx.internal.operators.OperatorSkipWhile; |
| 113 | +import rx.internal.operators.OperatorSubscribeOn; |
| 114 | +import rx.internal.operators.OperatorSwitch; |
| 115 | +import rx.internal.operators.OperatorTake; |
| 116 | +import rx.internal.operators.OperatorTakeLast; |
| 117 | +import rx.internal.operators.OperatorTakeLastTimed; |
| 118 | +import rx.internal.operators.OperatorTakeTimed; |
| 119 | +import rx.internal.operators.OperatorTakeUntil; |
| 120 | +import rx.internal.operators.OperatorTakeWhile; |
| 121 | +import rx.internal.operators.OperatorThrottleFirst; |
| 122 | +import rx.internal.operators.OperatorTimeInterval; |
| 123 | +import rx.internal.operators.OperatorTimeout; |
| 124 | +import rx.internal.operators.OperatorTimeoutWithSelector; |
| 125 | +import rx.internal.operators.OperatorTimestamp; |
| 126 | +import rx.internal.operators.OperatorToMap; |
| 127 | +import rx.internal.operators.OperatorToMultimap; |
| 128 | +import rx.internal.operators.OperatorToObservableList; |
| 129 | +import rx.internal.operators.OperatorToObservableSortedList; |
| 130 | +import rx.internal.operators.OperatorUnsubscribeOn; |
| 131 | +import rx.internal.operators.OperatorWindowWithObservable; |
| 132 | +import rx.internal.operators.OperatorWindowWithSize; |
| 133 | +import rx.internal.operators.OperatorWindowWithStartEndObservable; |
| 134 | +import rx.internal.operators.OperatorWindowWithTime; |
| 135 | +import rx.internal.operators.OperatorZip; |
| 136 | +import rx.internal.operators.OperatorZipIterable; |
| 137 | +import rx.internal.util.RxRingBuffer; |
21 | 138 | import rx.internal.util.ScalarSynchronousObservable;
|
22 | 139 | import rx.internal.util.UtilityFunctions;
|
23 |
| - |
24 |
| -import rx.observables.*; |
| 140 | +import rx.observables.BlockingObservable; |
| 141 | +import rx.observables.ConnectableObservable; |
| 142 | +import rx.observables.GroupedObservable; |
25 | 143 | import rx.observers.SafeSubscriber;
|
26 |
| -import rx.plugins.*; |
27 |
| -import rx.schedulers.*; |
28 |
| -import rx.subjects.*; |
| 144 | +import rx.plugins.RxJavaObservableExecutionHook; |
| 145 | +import rx.plugins.RxJavaPlugins; |
| 146 | +import rx.schedulers.Schedulers; |
| 147 | +import rx.schedulers.TimeInterval; |
| 148 | +import rx.schedulers.Timestamped; |
| 149 | +import rx.subjects.ReplaySubject; |
| 150 | +import rx.subjects.Subject; |
29 | 151 | import rx.subscriptions.Subscriptions;
|
30 | 152 |
|
31 | 153 | /**
|
@@ -182,6 +304,7 @@ public void call(Subscriber<? super R> o) {
|
182 | 304 | * @return the source Observable, transformed by the transformer function
|
183 | 305 | * @see <a href="https://github.com/ReactiveX/RxJava/wiki/Implementing-Your-Own-Operators">RxJava wiki: Implementing Your Own Operators</a>
|
184 | 306 | */
|
| 307 | + @SuppressWarnings("unchecked") |
185 | 308 | public <R> Observable<R> compose(Transformer<? super T, ? extends R> transformer) {
|
186 | 309 | return ((Transformer<T, R>) transformer).call(this);
|
187 | 310 | }
|
@@ -5054,6 +5177,43 @@ public final Observable<T> onBackpressureDrop() {
|
5054 | 5177 | return lift(new OperatorOnBackpressureDrop<T>());
|
5055 | 5178 | }
|
5056 | 5179 |
|
| 5180 | + /** |
| 5181 | + * Instructs an Observable that is emitting items faster than its observer can consume them is to |
| 5182 | + * block the producer thread. |
| 5183 | + * <p> |
| 5184 | + * The producer side can emit up to {@code maxQueueLength} onNext elements without blocking, but the |
| 5185 | + * consumer side considers the amount its downstream requested through {@code Producer.request(n)} |
| 5186 | + * and doesn't emit more than requested even if more is available. For example, using |
| 5187 | + * {@code onBackpressureBlock(384).observeOn(Schedulers.io())} will not throw a MissingBackpressureException. |
| 5188 | + * <p> |
| 5189 | + * Note that if the upstream Observable does support backpressure, this operator ignores that capability |
| 5190 | + * and doesn't propagate any backpressure requests from downstream. |
| 5191 | + * |
| 5192 | + * @param maxQueueLength the maximum number of items the producer can emit without blocking |
| 5193 | + * @return the source Observable modified to block {@code onNext} notifications on overflow |
| 5194 | + * @see <a href="https://github.com/ReactiveX/RxJava/wiki/Backpressure">RxJava wiki: Backpressure</a> |
| 5195 | + */ |
| 5196 | + public final Observable<T> onBackpressureBlock(int maxQueueLength) { |
| 5197 | + return lift(new OperatorOnBackpressureBlock<T>(maxQueueLength)); |
| 5198 | + } |
| 5199 | + /** |
| 5200 | + * Instructs an Observable that is emitting items faster than its observer can consume them is to |
| 5201 | + * block the producer thread if the number of undelivered onNext events reaches the system-wide ring buffer size. |
| 5202 | + * <p> |
| 5203 | + * The producer side can emit up to the system-wide ring buffer size onNext elements without blocking, but the |
| 5204 | + * consumer side considers the amount its downstream requested through {@code Producer.request(n)} |
| 5205 | + * and doesn't emit more than requested even if available. |
| 5206 | + * <p> |
| 5207 | + * Note that if the upstream Observable does support backpressure, this operator ignores that capability |
| 5208 | + * and doesn't propagate any backpressure requests from downstream. |
| 5209 | + * |
| 5210 | + * @return the source Observable modified to block {@code onNext} notifications on overflow |
| 5211 | + * @see <a href="https://github.com/ReactiveX/RxJava/wiki/Backpressure">RxJava wiki: Backpressure</a> |
| 5212 | + */ |
| 5213 | + public final Observable<T> onBackpressureBlock() { |
| 5214 | + return onBackpressureBlock(RxRingBuffer.SIZE); |
| 5215 | + } |
| 5216 | + |
5057 | 5217 | /**
|
5058 | 5218 | * Instructs an Observable to pass control to another Observable rather than invoking
|
5059 | 5219 | * {@link Observer#onError onError} if it encounters an error.
|
|
0 commit comments