@@ -19,6 +19,8 @@ package kotlinx.coroutines.experimental.channels
1919import kotlinx.coroutines.experimental.CancellationException
2020import kotlinx.coroutines.experimental.CoroutineScope
2121import kotlinx.coroutines.experimental.Job
22+ import kotlinx.coroutines.experimental.channels.Channel.Factory.CONFLATED
23+ import kotlinx.coroutines.experimental.channels.Channel.Factory.UNLIMITED
2224import kotlinx.coroutines.experimental.selects.SelectBuilder
2325import kotlinx.coroutines.experimental.selects.SelectInstance
2426import kotlinx.coroutines.experimental.selects.select
@@ -243,45 +245,57 @@ public interface ChannelIterator<out E> {
243245 * Conceptually, a channel is similar to [BlockingQueue][java.util.concurrent.BlockingQueue],
244246 * but it has suspending operations instead of blocking ones and it can be closed.
245247 *
246- * See [ Channel()][Channel.invoke] factory function for the description of available channel implementations.
248+ * See ` Channel(capacity)` factory function for the description of available channel implementations.
247249 */
248250public interface Channel <E > : SendChannel <E >, ReceiveChannel <E > {
249251 /* *
250- * Factory for channels .
252+ * Constants for channel factory function `Channel()` .
251253 */
252254 public companion object Factory {
253255 /* *
254- * Requests channel with unlimited capacity buffer in [ Channel()][invoke] factory function --
256+ * Requests channel with unlimited capacity buffer in ` Channel(...)` factory function --
255257 * the [LinkedListChannel] gets created.
256258 */
257259 public const val UNLIMITED = Int .MAX_VALUE
258260
259261 /* *
260- * Requests conflated channel in [ Channel()][invoke] factory function --
262+ * Requests conflated channel in ` Channel(...)` factory function --
261263 * the [ConflatedChannel] gets created.
262264 */
263265 public const val CONFLATED = - 1
264266
265267 /* *
266268 * Creates a channel with the specified buffer capacity (or without a buffer by default).
267- *
268- * The resulting channel type depends on the specified [capacity] parameter:
269- * * when `capacity` is 0 (default) -- creates [RendezvousChannel] without a buffer;
270- * * when `capacity` is [UNLIMITED] -- creates [LinkedListChannel] with buffer of unlimited size;
271- * * when `capacity` is [CONFLATED] -- creates [ConflatedChannel] that conflates back-to-back sends;
272- * * when `capacity` is positive, but less than [UNLIMITED] -- creates [ArrayChannel] with a buffer of the specified `capacity`;
273- * * otherwise -- throws [IllegalArgumentException].
269+ * @suppress **Deprecated**
274270 */
275- public operator fun <E > invoke (capacity : Int = 0): Channel <E > =
276- when (capacity) {
277- 0 -> RendezvousChannel ()
278- UNLIMITED -> LinkedListChannel ()
279- CONFLATED -> ConflatedChannel ()
280- else -> ArrayChannel (capacity)
281- }
271+ @Deprecated(" Replaced with top-level function" , level = DeprecationLevel .HIDDEN )
272+ public operator fun <E > invoke (capacity : Int = 0): Channel <E > = Channel (capacity)
282273 }
283274}
284275
276+ /* *
277+ * Creates a channel without a buffer -- [RendezvousChannel].
278+ */
279+ public fun <E > Channel (): Channel <E > = RendezvousChannel <E >()
280+
281+ /* *
282+ * Creates a channel with the specified buffer capacity (or without a buffer by default).
283+ *
284+ * The resulting channel type depends on the specified [capacity] parameter:
285+ * * when `capacity` is 0 -- creates [RendezvousChannel] without a buffer;
286+ * * when `capacity` is [Channel.UNLIMITED] -- creates [LinkedListChannel] with buffer of unlimited size;
287+ * * when `capacity` is [Channel.CONFLATED] -- creates [ConflatedChannel] that conflates back-to-back sends;
288+ * * when `capacity` is positive, but less than [UNLIMITED] -- creates [ArrayChannel] with a buffer of the specified `capacity`;
289+ * * otherwise -- throws [IllegalArgumentException].
290+ */
291+ public fun <E > Channel (capacity : Int ): Channel <E > =
292+ when (capacity) {
293+ 0 -> RendezvousChannel ()
294+ UNLIMITED -> LinkedListChannel ()
295+ CONFLATED -> ConflatedChannel ()
296+ else -> ArrayChannel (capacity)
297+ }
298+
285299/* *
286300 * Indicates attempt to [send][SendChannel.send] on [isClosedForSend][SendChannel.isClosedForSend] channel
287301 * that was closed _normally_. A _failed_ channel rethrows the original [close][SendChannel.close] cause
0 commit comments