Get rid of deprecated API where possible, add Channel.RENDEZVOUS
diff --git a/docs/channels.md b/docs/channels.md
index 70a4614..adf89ed 100644
--- a/docs/channels.md
+++ b/docs/channels.md
@@ -56,7 +56,7 @@
a blocking `take` operation it has a suspending [receive][ReceiveChannel.receive].
```kotlin
-fun main(args: Array<String>) = runBlocking<Unit> {
+fun main(args: Array<String>) = runBlocking {
val channel = Channel<Int>()
launch {
// this might be heavy CPU-consuming computation or async logic, we'll just send five squares
@@ -94,7 +94,7 @@
that all previously sent elements before the close are received:
```kotlin
-fun main(args: Array<String>) = runBlocking<Unit> {
+fun main(args: Array<String>) = runBlocking {
val channel = Channel<Int>()
launch {
for (x in 1..5) channel.send(x * x)
@@ -128,11 +128,11 @@
and an extension function [consumeEach], that replaces a `for` loop on the consumer side:
```kotlin
-fun CoroutineScope.produceSquares() = produce<Int> {
+fun CoroutineScope.produceSquares(): ReceiveChannel<Int> = produce {
for (x in 1..5) send(x * x)
}
-fun main(args: Array<String>) = runBlocking<Unit> {
+fun main(args: Array<String>) = runBlocking {
val squares = produceSquares()
squares.consumeEach { println(it) }
println("Done!")
@@ -165,7 +165,7 @@
In the below example the numbers are just squared:
```kotlin
-fun CoroutineScope.square(numbers: ReceiveChannel<Int>) = produce<Int> {
+fun CoroutineScope.square(numbers: ReceiveChannel<Int>): ReceiveChannel<Int> = produce {
for (x in numbers) send(x * x)
}
```
@@ -173,7 +173,7 @@
The main code starts and connects the whole pipeline:
```kotlin
-fun main(args: Array<String>) = runBlocking<Unit> {
+fun main(args: Array<String>) = runBlocking {
val numbers = produceNumbers() // produces integers from 1 and on
val squares = square(numbers) // squares integers
for (i in 1..5) println(squares.receive()) // print first five
@@ -238,7 +238,7 @@
the first ten prime numbers.
```kotlin
-fun main(args: Array<String>) = runBlocking<Unit> {
+fun main(args: Array<String>) = runBlocking {
var cur = numbersFrom(2)
for (i in 1..10) {
val prime = cur.receive()
@@ -370,7 +370,7 @@
(in this example we launch them in the context of the main thread as main coroutine's children):
```kotlin
-fun main(args: Array<String>) = runBlocking<Unit> {
+fun main(args: Array<String>) = runBlocking {
val channel = Channel<String>()
launch { sendString(channel, "foo", 200L) }
launch { sendString(channel, "BAR!", 500L) }
@@ -457,7 +457,7 @@
```kotlin
data class Ball(var hits: Int)
-fun main(args: Array<String>) = runBlocking<Unit> {
+fun main(args: Array<String>) = runBlocking {
val table = Channel<Ball>() // a shared table
launch { player("ping", table) }
launch { player("pong", table) }
@@ -508,7 +508,7 @@
```kotlin
fun main(args: Array<String>) = runBlocking<Unit> {
- val tickerChannel = ticker(delay = 100, initialDelay = 0) // create ticker channel
+ val tickerChannel = ticker(delayMillis = 100, initialDelayMillis = 0) // create ticker channel
var nextElement = withTimeoutOrNull(1) { tickerChannel.receive() }
println("Initial element is available immediately: $nextElement") // initial delay hasn't passed yet