From b971d5672afa29ff6185d9949508cce155518aef Mon Sep 17 00:00:00 2001 From: punitda Date: Tue, 13 Nov 2018 18:28:56 +0530 Subject: [PATCH] Javadoc : Explain explicitly about non-concurrency for Emitter interface methods --- src/main/java/io/reactivex/Emitter.java | 5 +++++ src/main/java/io/reactivex/Flowable.java | 25 ++++++++++++++++++++++ src/main/java/io/reactivex/Observable.java | 25 ++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/src/main/java/io/reactivex/Emitter.java b/src/main/java/io/reactivex/Emitter.java index 2f60f90478..0d95e80dcf 100644 --- a/src/main/java/io/reactivex/Emitter.java +++ b/src/main/java/io/reactivex/Emitter.java @@ -17,6 +17,11 @@ /** * Base interface for emitting signals in a push-fashion in various generator-like source * operators (create, generate). + *

+ * Note that the {@link Emitter#onNext}, {@link Emitter#onError} and + * {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously, + * never concurrently. Calling them from multiple threads is not supported and leads to an + * undefined behavior. * * @param the value type emitted */ diff --git a/src/main/java/io/reactivex/Flowable.java b/src/main/java/io/reactivex/Flowable.java index 666c7c765d..da4f800670 100644 --- a/src/main/java/io/reactivex/Flowable.java +++ b/src/main/java/io/reactivex/Flowable.java @@ -2210,6 +2210,11 @@ public static Flowable fromPublisher(final Publisher source) /** * Returns a cold, synchronous, stateless and backpressure-aware generator of values. + *

+ * Note that the {@link Emitter#onNext}, {@link Emitter#onError} and + * {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously, + * never concurrently and only while the function body is executing. Calling them from multiple threads + * or outside the function call is not supported and leads to an undefined behavior. *

*
Backpressure:
*
The operator honors downstream backpressure.
@@ -2236,6 +2241,11 @@ public static Flowable generate(final Consumer> generator) { /** * Returns a cold, synchronous, stateful and backpressure-aware generator of values. + *

+ * Note that the {@link Emitter#onNext}, {@link Emitter#onError} and + * {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously, + * never concurrently and only while the function body is executing. Calling them from multiple threads + * or outside the function call is not supported and leads to an undefined behavior. *

*
Backpressure:
*
The operator honors downstream backpressure.
@@ -2263,6 +2273,11 @@ public static Flowable generate(Callable initialState, final BiCons /** * Returns a cold, synchronous, stateful and backpressure-aware generator of values. + *

+ * Note that the {@link Emitter#onNext}, {@link Emitter#onError} and + * {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously, + * never concurrently and only while the function body is executing. Calling them from multiple threads + * or outside the function call is not supported and leads to an undefined behavior. *

*
Backpressure:
*
The operator honors downstream backpressure.
@@ -2292,6 +2307,11 @@ public static Flowable generate(Callable initialState, final BiCons /** * Returns a cold, synchronous, stateful and backpressure-aware generator of values. + *

+ * Note that the {@link Emitter#onNext}, {@link Emitter#onError} and + * {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously, + * never concurrently and only while the function body is executing. Calling them from multiple threads + * or outside the function call is not supported and leads to an undefined behavior. *

*
Backpressure:
*
The operator honors downstream backpressure.
@@ -2318,6 +2338,11 @@ public static Flowable generate(Callable initialState, BiFunction + * Note that the {@link Emitter#onNext}, {@link Emitter#onError} and + * {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously, + * never concurrently and only while the function body is executing. Calling them from multiple threads + * or outside the function call is not supported and leads to an undefined behavior. *
*
Backpressure:
*
The operator honors downstream backpressure.
diff --git a/src/main/java/io/reactivex/Observable.java b/src/main/java/io/reactivex/Observable.java index 8ab4059642..c022a0f9fa 100644 --- a/src/main/java/io/reactivex/Observable.java +++ b/src/main/java/io/reactivex/Observable.java @@ -1992,6 +1992,11 @@ public static Observable fromPublisher(Publisher publisher) * Returns a cold, synchronous and stateless generator of values. *

* + *

+ * Note that the {@link Emitter#onNext}, {@link Emitter#onError} and + * {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously, + * never concurrently and only while the function body is executing. Calling them from multiple threads + * or outside the function call is not supported and leads to an undefined behavior. *

*
Scheduler:
*
{@code generate} does not operate by default on a particular {@link Scheduler}.
@@ -2016,6 +2021,11 @@ public static Observable generate(final Consumer> generator) { * Returns a cold, synchronous and stateful generator of values. *

* + *

+ * Note that the {@link Emitter#onNext}, {@link Emitter#onError} and + * {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously, + * never concurrently and only while the function body is executing. Calling them from multiple threads + * or outside the function call is not supported and leads to an undefined behavior. *

*
Scheduler:
*
{@code generate} does not operate by default on a particular {@link Scheduler}.
@@ -2041,6 +2051,11 @@ public static Observable generate(Callable initialState, final BiCo * Returns a cold, synchronous and stateful generator of values. *

* + *

+ * Note that the {@link Emitter#onNext}, {@link Emitter#onError} and + * {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously, + * never concurrently and only while the function body is executing. Calling them from multiple threads + * or outside the function call is not supported and leads to an undefined behavior. *

*
Scheduler:
*
{@code generate} does not operate by default on a particular {@link Scheduler}.
@@ -2071,6 +2086,11 @@ public static Observable generate( * Returns a cold, synchronous and stateful generator of values. *

* + *

+ * Note that the {@link Emitter#onNext}, {@link Emitter#onError} and + * {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously, + * never concurrently and only while the function body is executing. Calling them from multiple threads + * or outside the function call is not supported and leads to an undefined behavior. *

*
Scheduler:
*
{@code generate} does not operate by default on a particular {@link Scheduler}.
@@ -2096,6 +2116,11 @@ public static Observable generate(Callable initialState, BiFunction * Returns a cold, synchronous and stateful generator of values. *

* + *

+ * Note that the {@link Emitter#onNext}, {@link Emitter#onError} and + * {@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously, + * never concurrently and only while the function body is executing. Calling them from multiple threads + * or outside the function call is not supported and leads to an undefined behavior. *

*
Scheduler:
*
{@code generate} does not operate by default on a particular {@link Scheduler}.