@@ -32,9 +32,7 @@ import kotlinx.coroutines.experimental.yield
3232public interface SendChannel <in E > {
3333 /* *
3434 * 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.
3836 */
3937 public val isClosedForSend: Boolean
4038
@@ -46,8 +44,7 @@ public interface SendChannel<in E> {
4644
4745 /* *
4846 * 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).
5148 *
5249 * Note, that closing a channel _after_ this function had suspended does not cause this suspended send invocation
5350 * 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> {
7673 * as parameter is sent to the channel. When the clause is selected the reference to this channel
7774 * is passed into the corresponding block.
7875 *
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).
8277 */
8378 public val onSend: SelectClause2 <E , SendChannel <E >>
8479
8580 /* *
8681 * Adds [element] into this queue if it is possible to do so immediately without violating capacity restrictions
8782 * 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).
9084 */
9185 public fun offer (element : E ): Boolean
9286
@@ -98,9 +92,9 @@ public interface SendChannel<in E> {
9892 * on the side of [ReceiveChannel] starts returning `true` only after all previously sent elements
9993 * are received.
10094 *
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.
10498 */
10599 public fun close (cause : Throwable ? = null): Boolean
106100}
@@ -150,15 +144,14 @@ public interface ReceiveChannel<out E> {
150144 /* *
151145 * Clause for [select] expression of [receive] suspending function that selects with the element that
152146 * 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).
156149 */
157150 public val onReceive: SelectClause1 <E >
158151
159152 /* *
160153 * 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
162155 * or throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
163156 *
164157 * 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> {
181174 /* *
182175 * Clause for [select] expression of [receiveOrNull] suspending function that selects with the element that
183176 * 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
185178 * the original [close][SendChannel.close] cause exception if the channel has _failed_.
186179 */
187180 public val onReceiveOrNull: SelectClause1 <E ?>
188181
189182 /* *
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_.
193186 */
194187 public fun poll (): E ?
195188
196189 /* *
197190 * 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
199192 * throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
200193 */
201194 public operator fun iterator (): ChannelIterator <E >
@@ -209,7 +202,7 @@ public interface ChannelIterator<out E> {
209202 /* *
210203 * Returns `true` if the channel has more elements suspending the caller while this channel
211204 * [isEmpty][ReceiveChannel.isEmpty] or returns `false` if the channel
212- * [isClosedForReceive][ReceiveChannel.isClosedForReceive] _normally_ .
205+ * [isClosedForReceive][ReceiveChannel.isClosedForReceive] without cause .
213206 * It throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
214207 *
215208 * This function retrieves and removes the element from this channel for the subsequent invocation
@@ -232,7 +225,7 @@ public interface ChannelIterator<out E> {
232225 /* *
233226 * Retrieves and removes the element from this channel suspending the caller while this channel
234227 * [isEmpty][ReceiveChannel.isEmpty] or throws [ClosedReceiveChannelException] if the channel
235- * [isClosedForReceive][ReceiveChannel.isClosedForReceive].
228+ * [isClosedForReceive][ReceiveChannel.isClosedForReceive] without cause .
236229 * It throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
237230 *
238231 * 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> =
308301
309302/* *
310303 * 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
312305 * exception on send attempts.
313306 */
314307public class ClosedSendChannelException (message : String? ) : CancellationException(message)
315308
316309/* *
317310 * 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
319312 * exception on receive attempts.
320313 */
321314public class ClosedReceiveChannelException (message : String? ) : NoSuchElementException(message)
0 commit comments