You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* <p>The processor does not coordinate backpressure for its subscribers and implements a weaker onSubscribe which
33
-
* calls requests Long.MAX_VALUE from the incoming Subscriptions. This makes it possible to subscribe the PublishProcessor
34
-
* to multiple sources (note on serialization though) unlike the standard Subscriber contract. Child subscribers, however, are not overflown but receive an
35
-
* IllegalStateException in case their requested amount is zero.
36
-
*
37
-
* <p>The implementation of onXXX methods are technically thread-safe but non-serialized calls
38
-
* to them may lead to undefined state in the currently subscribed Subscribers.
39
-
*
40
-
* <p>Due to the nature Flowables are constructed, the PublishProcessor can't be instantiated through
41
-
* {@code new} but must be created via the {@link #create()} method.
31
+
* <p>
32
+
* This processor does not have a public constructor by design; a new empty instance of this
33
+
* {@code PublishProcessor} can be created via the {@link #create()} method.
34
+
* <p>
35
+
* Since a {@code PublishProcessor} is a Reactive Streams {@code Processor} type,
36
+
* {@code null}s are not allowed (<a href="https://github.com/reactive-streams/reactive-streams-jvm#2.13">Rule 2.13</a>) as
37
+
* parameters to {@link #onNext(Object)} and {@link #onError(Throwable)}. Such calls will result in a
38
+
* {@link NullPointerException} being thrown and the processor's state is not changed.
39
+
* <p>
40
+
* {@code PublishProcessor} is a {@link io.reactivex.Flowable} as well as a {@link FlowableProcessor},
41
+
* however, it does not coordinate backpressure between different subscribers and between an
42
+
* upstream source and a subscriber. If an upstream item is received via {@link #onNext(Object)}, if
43
+
* a subscriber is not ready to receive an item, that subscriber is terminated via a {@link MissingBackpressureException}.
44
+
* To avoid this case, use {@link #offer(Object)} and retry sometime later if it returned false.
45
+
* The {@code PublishProcessor}'s {@link Subscriber}-side consumes items in an unbounded manner.
46
+
* <p>
47
+
* For a multicasting processor type that also coordinates between the downstream {@code Subscriber}s and the upstream
48
+
* source as well, consider using {@link MulticastProcessor}.
49
+
* <p>
50
+
* When this {@code PublishProcessor} is terminated via {@link #onError(Throwable)} or {@link #onComplete()},
51
+
* late {@link Subscriber}s only receive the respective terminal event.
52
+
* <p>
53
+
* Unlike a {@link BehaviorProcessor}, a {@code PublishProcessor} doesn't retain/cache items, therefore, a new
54
+
* {@code Subscriber} won't receive any past items.
55
+
* <p>
56
+
* Even though {@code PublishProcessor} implements the {@link Subscriber} interface, calling
57
+
* {@code onSubscribe} is not required (<a href="https://github.com/reactive-streams/reactive-streams-jvm#2.12">Rule 2.12</a>)
58
+
* if the processor is used as a standalone source. However, calling {@code onSubscribe}
59
+
* after the {@code PublishProcessor} reached its terminal state will result in the
60
+
* given {@link Subscription} being canceled immediately.
* is required to be serialized (called from the same thread or called non-overlappingly from different threads
64
+
* through external means of serialization). The {@link #toSerialized()} method available to all {@link FlowableProcessor}s
65
+
* provides such serialization and also protects against reentrance (i.e., when a downstream {@code Subscriber}
66
+
* consuming this processor also wants to call {@link #onNext(Object)} on this processor recursively).
67
+
* Note that serializing over {@link #offer(Object)} is not supported through {@code toSerialized()} because it is a method
68
+
* available on the {@code PublishProcessor} and {@code BehaviorProcessor} classes only.
69
+
* <p>
70
+
* This {@code PublishProcessor} supports the standard state-peeking methods {@link #hasComplete()}, {@link #hasThrowable()},
71
+
* {@link #getThrowable()} and {@link #hasSubscribers()}.
72
+
* <dl>
73
+
* <dt><b>Backpressure:</b></dt>
74
+
* <dd>The processor does not coordinate backpressure for its subscribers and implements a weaker {@code onSubscribe} which
75
+
* calls requests Long.MAX_VALUE from the incoming Subscriptions. This makes it possible to subscribe the {@code PublishProcessor}
76
+
* to multiple sources (note on serialization though) unlike the standard {@code Subscriber} contract. Child subscribers, however, are not overflown but receive an
77
+
* {@link IllegalStateException} in case their requested amount is zero.</dd>
78
+
* <dt><b>Scheduler:</b></dt>
79
+
* <dd>{@code PublishProcessor} does not operate by default on a particular {@link io.reactivex.Scheduler} and
80
+
* the {@code Subscriber}s get notified on the thread the respective {@code onXXX} methods were invoked.</dd>
81
+
* <dt><b>Error handling:</b></dt>
82
+
* <dd>When the {@link #onError(Throwable)} is called, the {@code PublishProcessor} enters into a terminal state
83
+
* and emits the same {@code Throwable} instance to the last set of {@code Subscriber}s. During this emission,
84
+
* if one or more {@code Subscriber}s cancel their respective {@code Subscription}s, the
85
+
* {@code Throwable} is delivered to the global error handler via
86
+
* {@link io.reactivex.plugins.RxJavaPlugins#onError(Throwable)} (multiple times if multiple {@code Subscriber}s
87
+
* cancel at once).
88
+
* If there were no {@code Subscriber}s subscribed to this {@code PublishProcessor} when the {@code onError()}
89
+
* was called, the global error handler is not invoked.
90
+
* </dd>
91
+
* </dl>
42
92
*
43
93
* Example usage:
44
94
* <pre> {@code
@@ -55,6 +105,7 @@
55
105
56
106
} </pre>
57
107
* @param <T> the value type multicasted to Subscribers.
0 commit comments