Skip to content

Commit e82b82e

Browse files
punitdaakarnokd
authored andcommitted
Javadoc : Explain explicitly about non-concurrency for Emitter interface methods (#6305)
1 parent 6afd2b8 commit e82b82e

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

src/main/java/io/reactivex/Emitter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
/**
1818
* Base interface for emitting signals in a push-fashion in various generator-like source
1919
* operators (create, generate).
20+
* <p>
21+
* Note that the {@link Emitter#onNext}, {@link Emitter#onError} and
22+
* {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously,
23+
* never concurrently. Calling them from multiple threads is not supported and leads to an
24+
* undefined behavior.
2025
*
2126
* @param <T> the value type emitted
2227
*/

src/main/java/io/reactivex/Flowable.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,6 +2210,11 @@ public static <T> Flowable<T> fromPublisher(final Publisher<? extends T> source)
22102210

22112211
/**
22122212
* Returns a cold, synchronous, stateless and backpressure-aware generator of values.
2213+
* <p>
2214+
* Note that the {@link Emitter#onNext}, {@link Emitter#onError} and
2215+
* {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously,
2216+
* never concurrently and only while the function body is executing. Calling them from multiple threads
2217+
* or outside the function call is not supported and leads to an undefined behavior.
22132218
* <dl>
22142219
* <dt><b>Backpressure:</b></dt>
22152220
* <dd>The operator honors downstream backpressure.</dd>
@@ -2236,6 +2241,11 @@ public static <T> Flowable<T> generate(final Consumer<Emitter<T>> generator) {
22362241

22372242
/**
22382243
* Returns a cold, synchronous, stateful and backpressure-aware generator of values.
2244+
* <p>
2245+
* Note that the {@link Emitter#onNext}, {@link Emitter#onError} and
2246+
* {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously,
2247+
* never concurrently and only while the function body is executing. Calling them from multiple threads
2248+
* or outside the function call is not supported and leads to an undefined behavior.
22392249
* <dl>
22402250
* <dt><b>Backpressure:</b></dt>
22412251
* <dd>The operator honors downstream backpressure.</dd>
@@ -2263,6 +2273,11 @@ public static <T, S> Flowable<T> generate(Callable<S> initialState, final BiCons
22632273

22642274
/**
22652275
* Returns a cold, synchronous, stateful and backpressure-aware generator of values.
2276+
* <p>
2277+
* Note that the {@link Emitter#onNext}, {@link Emitter#onError} and
2278+
* {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously,
2279+
* never concurrently and only while the function body is executing. Calling them from multiple threads
2280+
* or outside the function call is not supported and leads to an undefined behavior.
22662281
* <dl>
22672282
* <dt><b>Backpressure:</b></dt>
22682283
* <dd>The operator honors downstream backpressure.</dd>
@@ -2292,6 +2307,11 @@ public static <T, S> Flowable<T> generate(Callable<S> initialState, final BiCons
22922307

22932308
/**
22942309
* Returns a cold, synchronous, stateful and backpressure-aware generator of values.
2310+
* <p>
2311+
* Note that the {@link Emitter#onNext}, {@link Emitter#onError} and
2312+
* {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously,
2313+
* never concurrently and only while the function body is executing. Calling them from multiple threads
2314+
* or outside the function call is not supported and leads to an undefined behavior.
22952315
* <dl>
22962316
* <dt><b>Backpressure:</b></dt>
22972317
* <dd>The operator honors downstream backpressure.</dd>
@@ -2318,6 +2338,11 @@ public static <T, S> Flowable<T> generate(Callable<S> initialState, BiFunction<S
23182338

23192339
/**
23202340
* Returns a cold, synchronous, stateful and backpressure-aware generator of values.
2341+
* <p>
2342+
* Note that the {@link Emitter#onNext}, {@link Emitter#onError} and
2343+
* {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously,
2344+
* never concurrently and only while the function body is executing. Calling them from multiple threads
2345+
* or outside the function call is not supported and leads to an undefined behavior.
23212346
* <dl>
23222347
* <dt><b>Backpressure:</b></dt>
23232348
* <dd>The operator honors downstream backpressure.</dd>

src/main/java/io/reactivex/Observable.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,6 +1992,11 @@ public static <T> Observable<T> fromPublisher(Publisher<? extends T> publisher)
19921992
* Returns a cold, synchronous and stateless generator of values.
19931993
* <p>
19941994
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/generate.2.png" alt="">
1995+
* <p>
1996+
* Note that the {@link Emitter#onNext}, {@link Emitter#onError} and
1997+
* {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously,
1998+
* never concurrently and only while the function body is executing. Calling them from multiple threads
1999+
* or outside the function call is not supported and leads to an undefined behavior.
19952000
* <dl>
19962001
* <dt><b>Scheduler:</b></dt>
19972002
* <dd>{@code generate} does not operate by default on a particular {@link Scheduler}.</dd>
@@ -2016,6 +2021,11 @@ public static <T> Observable<T> generate(final Consumer<Emitter<T>> generator) {
20162021
* Returns a cold, synchronous and stateful generator of values.
20172022
* <p>
20182023
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/generate.2.png" alt="">
2024+
* <p>
2025+
* Note that the {@link Emitter#onNext}, {@link Emitter#onError} and
2026+
* {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously,
2027+
* never concurrently and only while the function body is executing. Calling them from multiple threads
2028+
* or outside the function call is not supported and leads to an undefined behavior.
20192029
* <dl>
20202030
* <dt><b>Scheduler:</b></dt>
20212031
* <dd>{@code generate} does not operate by default on a particular {@link Scheduler}.</dd>
@@ -2041,6 +2051,11 @@ public static <T, S> Observable<T> generate(Callable<S> initialState, final BiCo
20412051
* Returns a cold, synchronous and stateful generator of values.
20422052
* <p>
20432053
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/generate.2.png" alt="">
2054+
* <p>
2055+
* Note that the {@link Emitter#onNext}, {@link Emitter#onError} and
2056+
* {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously,
2057+
* never concurrently and only while the function body is executing. Calling them from multiple threads
2058+
* or outside the function call is not supported and leads to an undefined behavior.
20442059
* <dl>
20452060
* <dt><b>Scheduler:</b></dt>
20462061
* <dd>{@code generate} does not operate by default on a particular {@link Scheduler}.</dd>
@@ -2071,6 +2086,11 @@ public static <T, S> Observable<T> generate(
20712086
* Returns a cold, synchronous and stateful generator of values.
20722087
* <p>
20732088
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/generate.2.png" alt="">
2089+
* <p>
2090+
* Note that the {@link Emitter#onNext}, {@link Emitter#onError} and
2091+
* {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously,
2092+
* never concurrently and only while the function body is executing. Calling them from multiple threads
2093+
* or outside the function call is not supported and leads to an undefined behavior.
20742094
* <dl>
20752095
* <dt><b>Scheduler:</b></dt>
20762096
* <dd>{@code generate} does not operate by default on a particular {@link Scheduler}.</dd>
@@ -2096,6 +2116,11 @@ public static <T, S> Observable<T> generate(Callable<S> initialState, BiFunction
20962116
* Returns a cold, synchronous and stateful generator of values.
20972117
* <p>
20982118
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/generate.2.png" alt="">
2119+
* <p>
2120+
* Note that the {@link Emitter#onNext}, {@link Emitter#onError} and
2121+
* {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously,
2122+
* never concurrently and only while the function body is executing. Calling them from multiple threads
2123+
* or outside the function call is not supported and leads to an undefined behavior.
20992124
* <dl>
21002125
* <dt><b>Scheduler:</b></dt>
21012126
* <dd>{@code generate} does not operate by default on a particular {@link Scheduler}.</dd>

0 commit comments

Comments
 (0)