@@ -23,12 +23,17 @@ import kotlin.jvm.*
23
23
*/
24
24
public interface SendChannel <in E > {
25
25
/* *
26
- * Returns `true` if this channel was closed by an invocation of [close]. This means that
27
- * calling [send] will result in an exception.
26
+ * Returns `true` if this channel was closed by an invocation of [close] or its receiving side was [cancelled][ReceiveChannel.cancel].
27
+ * This means that calling [send] will result in an exception.
28
28
*
29
- * **Note: This is an experimental api.** This property may change its semantics and/or name in the future.
29
+ * Note that if this property returns `false`, it does not guarantee that consecutive call to [send] will succeed, as the
30
+ * channel can be concurrently closed right after the check. For such scenarios, it is recommended to use [trySend] instead.
31
+ *
32
+ * @see SendChannel.trySend
33
+ * @see SendChannel.close
34
+ * @see ReceiveChannel.cancel
30
35
*/
31
- @ExperimentalCoroutinesApi
36
+ @DelicateCoroutinesApi
32
37
public val isClosedForSend: Boolean
33
38
34
39
/* *
@@ -174,14 +179,20 @@ public interface SendChannel<in E> {
174
179
public interface ReceiveChannel <out E > {
175
180
/* *
176
181
* Returns `true` if this channel was closed by invocation of [close][SendChannel.close] on the [SendChannel]
177
- * side and all previously sent items were already received. This means that calling [receive]
178
- * will result in a [ClosedReceiveChannelException]. If the channel was closed because of an exception, it
179
- * is considered closed, too, but is called a _failed_ channel. All suspending attempts to receive
180
- * an element from a failed channel throw the original [close][SendChannel.close] cause exception.
182
+ * side and all previously sent items were already received, or if the receiving side was [cancelled][ReceiveChannel.cancel].
183
+ *
184
+ * This means that calling [receive] will result in a [ClosedReceiveChannelException] or a corresponding cancellation cause.
185
+ * If the channel was closed because of an exception, it is considered closed, too, but is called a _failed_ channel.
186
+ * All suspending attempts to receive an element from a failed channel throw the original [close][SendChannel.close] cause exception.
181
187
*
182
- * **Note: This is an experimental api.** This property may change its semantics and/or name in the future.
188
+ * Note that if this property returns `false`, it does not guarantee that consecutive call to [receive] will succeed, as the
189
+ * channel can be concurrently closed right after the check. For such scenarios, it is recommended to use [receiveCatching] instead.
190
+ *
191
+ * @see ReceiveChannel.receiveCatching
192
+ * @see ReceiveChannel.cancel
193
+ * @see SendChannel.close
183
194
*/
184
- @ExperimentalCoroutinesApi
195
+ @DelicateCoroutinesApi
185
196
public val isClosedForReceive: Boolean
186
197
187
198
/* *
0 commit comments