@@ -167,8 +167,15 @@ public interface SharedFlow<out T> : Flow<T> {
167
167
*/
168
168
public interface MutableSharedFlow <T > : SharedFlow <T >, FlowCollector <T > {
169
169
/* *
170
- * Emits a [value] to this shared flow, suspending on buffer overflow if the shared flow was created
171
- * with the default [BufferOverflow.SUSPEND] strategy.
170
+ * Emits a [value] to this shared flow, suspending on buffer overflow.
171
+ *
172
+ * This call can suspend only when the [BufferOverflow] strategy is
173
+ * [SUSPEND][BufferOverflow.SUSPEND] **and** there are subscribers collecting this shared flow.
174
+ *
175
+ * If there are no subscribers, the buffer is not used.
176
+ * Instead, the most recently emitted value is simply stored into
177
+ * the replay cache if one was configured, displacing the older elements there,
178
+ * or dropped if no replay cache was configured.
172
179
*
173
180
* See [tryEmit] for a non-suspending variant of this function.
174
181
*
@@ -179,12 +186,16 @@ public interface MutableSharedFlow<T> : SharedFlow<T>, FlowCollector<T> {
179
186
180
187
/* *
181
188
* Tries to emit a [value] to this shared flow without suspending. It returns `true` if the value was
182
- * emitted successfully. When this function returns `false`, it means that the call to a plain [emit]
183
- * function will suspend until there is a buffer space available.
189
+ * emitted successfully (see below). When this function returns `false`, it means that a call to a plain [emit]
190
+ * function would suspend until there is buffer space available.
191
+ *
192
+ * This call can return `false` only when the [BufferOverflow] strategy is
193
+ * [SUSPEND][BufferOverflow.SUSPEND] **and** there are subscribers collecting this shared flow.
184
194
*
185
- * A shared flow configured with a [BufferOverflow] strategy other than [SUSPEND][BufferOverflow.SUSPEND]
186
- * (either [DROP_OLDEST][BufferOverflow.DROP_OLDEST] or [DROP_LATEST][BufferOverflow.DROP_LATEST]) never
187
- * suspends on [emit], and thus `tryEmit` to such a shared flow always returns `true`.
195
+ * If there are no subscribers, the buffer is not used.
196
+ * Instead, the most recently emitted value is simply stored into
197
+ * the replay cache if one was configured, displacing the older elements there,
198
+ * or dropped if no replay cache was configured. In any case, `tryEmit` returns `true`.
188
199
*
189
200
* This method is **thread-safe** and can be safely invoked from concurrent coroutines without
190
201
* external synchronization.
0 commit comments