@@ -32,9 +32,7 @@ import kotlinx.coroutines.experimental.yield
32
32
public interface SendChannel <in E > {
33
33
/* *
34
34
* Returns `true` if this channel was closed by invocation of [close] and thus
35
- * the [send] attempt throws [ClosedSendChannelException]. If the channel was closed because of the exception, it
36
- * is considered closed, too, but it is called a _failed_ channel. All suspending attempts to send
37
- * an element to a failed channel throw the original [close] cause exception.
35
+ * the [send] and [offer] attempts throws exception.
38
36
*/
39
37
public val isClosedForSend: Boolean
40
38
@@ -46,8 +44,7 @@ public interface SendChannel<in E> {
46
44
47
45
/* *
48
46
* Adds [element] into to this channel, suspending the caller while this channel [isFull],
49
- * or throws [ClosedSendChannelException] if the channel [isClosedForSend] _normally_.
50
- * It throws the original [close] cause exception if the channel has _failed_.
47
+ * or throws exception if the channel [isClosedForSend] (see [close] for details).
51
48
*
52
49
* Note, that closing a channel _after_ this function had suspended does not cause this suspended send invocation
53
50
* to abort, because closing a channel is conceptually like sending a special "close token" over this channel.
@@ -76,17 +73,14 @@ public interface SendChannel<in E> {
76
73
* as parameter is sent to the channel. When the clause is selected the reference to this channel
77
74
* is passed into the corresponding block.
78
75
*
79
- * The [select] invocation fails with [ClosedSendChannelException] if the channel
80
- * [isClosedForSend][SendChannel.isClosedForSend] _normally_ or with the original
81
- * [close][SendChannel.close] cause exception if the channel has _failed_.
76
+ * The [select] invocation fails with exception if the channel [isClosedForSend] (see [close] for details).
82
77
*/
83
78
public val onSend: SelectClause2 <E , SendChannel <E >>
84
79
85
80
/* *
86
81
* Adds [element] into this queue if it is possible to do so immediately without violating capacity restrictions
87
82
* and returns `true`. Otherwise, it returns `false` immediately
88
- * or throws [ClosedSendChannelException] if the channel [isClosedForSend] _normally_.
89
- * It throws the original [close] cause exception if the channel has _failed_.
83
+ * or throws exception if the channel [isClosedForSend] (see [close] for details).
90
84
*/
91
85
public fun offer (element : E ): Boolean
92
86
@@ -98,9 +92,9 @@ public interface SendChannel<in E> {
98
92
* on the side of [ReceiveChannel] starts returning `true` only after all previously sent elements
99
93
* are received.
100
94
*
101
- * A channel that was closed without a [cause], is considered to be _closed normally_ .
102
- * A channel that was closed with non-null [cause] is called a _failed channel_ . Attempts to send or
103
- * receive on a failed channel throw this cause exception.
95
+ * A channel that was closed without a [cause] throws [ClosedSendChannelException] on attempts to send or receive .
96
+ * A channel that was closed with non-null [cause] is called a _failed_ channel . Attempts to send or
97
+ * receive on a failed channel throw the specified [ cause] exception.
104
98
*/
105
99
public fun close (cause : Throwable ? = null): Boolean
106
100
}
@@ -150,15 +144,14 @@ public interface ReceiveChannel<out E> {
150
144
/* *
151
145
* Clause for [select] expression of [receive] suspending function that selects with the element that
152
146
* is received from the channel.
153
- * The [select] invocation fails with [ClosedReceiveChannelException] if the channel
154
- * [isClosedForReceive][ReceiveChannel.isClosedForReceive] _normally_ or with the original
155
- * [close][SendChannel.close] cause exception if the channel has _failed_.
147
+ * The [select] invocation fails with exception if the channel
148
+ * [isClosedForReceive] (see [close][SendChannel.close] for details).
156
149
*/
157
150
public val onReceive: SelectClause1 <E >
158
151
159
152
/* *
160
153
* Retrieves and removes the element from this channel suspending the caller while this channel [isEmpty]
161
- * or returns `null` if the channel is [closed][isClosedForReceive] _normally_,
154
+ * or returns `null` if the channel is [closed][isClosedForReceive] without cause
162
155
* or throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
163
156
*
164
157
* This suspending function is cancellable. If the [Job] of the current coroutine is cancelled or completed while this
@@ -181,21 +174,21 @@ public interface ReceiveChannel<out E> {
181
174
/* *
182
175
* Clause for [select] expression of [receiveOrNull] suspending function that selects with the element that
183
176
* is received from the channel or selects with `null` if if the channel
184
- * [isClosedForReceive][ReceiveChannel.isClosedForReceive] _normally_ . The [select] invocation fails with
177
+ * [isClosedForReceive] without cause . The [select] invocation fails with
185
178
* the original [close][SendChannel.close] cause exception if the channel has _failed_.
186
179
*/
187
180
public val onReceiveOrNull: SelectClause1 <E ?>
188
181
189
182
/* *
190
- * Retrieves and removes the head of this queue , or returns `null` if this queue [isEmpty]
191
- * or is [closed][ isClosedForReceive] _normally_,
192
- * or throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
183
+ * Retrieves and removes the element from this channel , or returns `null` if this channel [isEmpty]
184
+ * or is [isClosedForReceive] without cause.
185
+ * It throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
193
186
*/
194
187
public fun poll (): E ?
195
188
196
189
/* *
197
190
* Returns new iterator to receive elements from this channels using `for` loop.
198
- * Iteration completes normally when the channel is [closed][ isClosedForReceive] _normally_ and
191
+ * Iteration completes normally when the channel is [isClosedForReceive] without cause and
199
192
* throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
200
193
*/
201
194
public operator fun iterator (): ChannelIterator <E >
@@ -209,7 +202,7 @@ public interface ChannelIterator<out E> {
209
202
/* *
210
203
* Returns `true` if the channel has more elements suspending the caller while this channel
211
204
* [isEmpty][ReceiveChannel.isEmpty] or returns `false` if the channel
212
- * [isClosedForReceive][ReceiveChannel.isClosedForReceive] _normally_ .
205
+ * [isClosedForReceive][ReceiveChannel.isClosedForReceive] without cause .
213
206
* It throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
214
207
*
215
208
* This function retrieves and removes the element from this channel for the subsequent invocation
@@ -232,7 +225,7 @@ public interface ChannelIterator<out E> {
232
225
/* *
233
226
* Retrieves and removes the element from this channel suspending the caller while this channel
234
227
* [isEmpty][ReceiveChannel.isEmpty] or throws [ClosedReceiveChannelException] if the channel
235
- * [isClosedForReceive][ReceiveChannel.isClosedForReceive].
228
+ * [isClosedForReceive][ReceiveChannel.isClosedForReceive] without cause .
236
229
* It throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
237
230
*
238
231
* This suspending function is cancellable. If the [Job] of the current coroutine is cancelled or completed while this
@@ -308,14 +301,14 @@ public fun <E> Channel(capacity: Int): Channel<E> =
308
301
309
302
/* *
310
303
* Indicates attempt to [send][SendChannel.send] on [isClosedForSend][SendChannel.isClosedForSend] channel
311
- * that was closed _normally_ . A _failed_ channel rethrows the original [close][SendChannel.close] cause
304
+ * that was closed without a cause . A _failed_ channel rethrows the original [close][SendChannel.close] cause
312
305
* exception on send attempts.
313
306
*/
314
307
public class ClosedSendChannelException (message : String? ) : CancellationException(message)
315
308
316
309
/* *
317
310
* Indicates attempt to [receive][ReceiveChannel.receive] on [isClosedForReceive][ReceiveChannel.isClosedForReceive]
318
- * channel that was closed _normally_ . A _failed_ channel rethrows the original [close][SendChannel.close] cause
311
+ * channel that was closed without a cause . A _failed_ channel rethrows the original [close][SendChannel.close] cause
319
312
* exception on receive attempts.
320
313
*/
321
314
public class ClosedReceiveChannelException (message : String? ) : NoSuchElementException(message)
0 commit comments