Skip to content

Commit 65e6c8c

Browse files
AlexanderPrendotaelizarov
authored andcommitted
Make examples runnable
* Also drop args from fun main
1 parent 56ee233 commit 65e6c8c

File tree

102 files changed

+828
-518
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+828
-518
lines changed

core/kotlinx-coroutines-core/test/guide/example-basic-01.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package kotlinx.coroutines.guide.basic01
77

88
import kotlinx.coroutines.*
99

10-
fun main(args: Array<String>) {
10+
fun main() {
1111
GlobalScope.launch { // launch new coroutine in background and continue
1212
delay(1000L) // non-blocking delay for 1 second (default time unit is ms)
1313
println("World!") // print after delay

core/kotlinx-coroutines-core/test/guide/example-basic-02.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package kotlinx.coroutines.guide.basic02
77

88
import kotlinx.coroutines.*
99

10-
fun main(args: Array<String>) {
10+
fun main() {
1111
GlobalScope.launch { // launch new coroutine in background and continue
1212
delay(1000L)
1313
println("World!")

core/kotlinx-coroutines-core/test/guide/example-basic-02b.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package kotlinx.coroutines.guide.basic02b
77

88
import kotlinx.coroutines.*
99

10-
fun main(args: Array<String>) = runBlocking<Unit> { // start main coroutine
10+
fun main() = runBlocking<Unit> { // start main coroutine
1111
GlobalScope.launch { // launch new coroutine in background and continue
1212
delay(1000L)
1313
println("World!")

core/kotlinx-coroutines-core/test/guide/example-basic-03.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ package kotlinx.coroutines.guide.basic03
77

88
import kotlinx.coroutines.*
99

10-
fun main(args: Array<String>) = runBlocking {
10+
fun main() = runBlocking {
11+
//sampleStart
1112
val job = GlobalScope.launch { // launch new coroutine and keep a reference to its Job
1213
delay(1000L)
1314
println("World!")
1415
}
1516
println("Hello,")
1617
job.join() // wait until child coroutine completes
18+
//sampleEnd
1719
}

core/kotlinx-coroutines-core/test/guide/example-basic-03s.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package kotlinx.coroutines.guide.basic03s
77

88
import kotlinx.coroutines.*
99

10-
fun main(args: Array<String>) = runBlocking { // this: CoroutineScope
10+
fun main() = runBlocking { // this: CoroutineScope
1111
launch { // launch new coroutine in the scope of runBlocking
1212
delay(1000L)
1313
println("World!")

core/kotlinx-coroutines-core/test/guide/example-basic-04.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package kotlinx.coroutines.guide.basic04
77

88
import kotlinx.coroutines.*
99

10-
fun main(args: Array<String>) = runBlocking { // this: CoroutineScope
10+
fun main() = runBlocking { // this: CoroutineScope
1111
launch {
1212
delay(200L)
1313
println("Task from runBlocking")

core/kotlinx-coroutines-core/test/guide/example-basic-05.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package kotlinx.coroutines.guide.basic05
77

88
import kotlinx.coroutines.*
99

10-
fun main(args: Array<String>) = runBlocking {
10+
fun main() = runBlocking {
1111
launch { doWorld() }
1212
println("Hello,")
1313
}

core/kotlinx-coroutines-core/test/guide/example-basic-06.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package kotlinx.coroutines.guide.basic06
77

88
import kotlinx.coroutines.*
99

10-
fun main(args: Array<String>) = runBlocking {
10+
fun main() = runBlocking {
1111
repeat(100_000) { // launch a lot of coroutines
1212
launch {
1313
delay(1000L)

core/kotlinx-coroutines-core/test/guide/example-basic-07.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ package kotlinx.coroutines.guide.basic07
77

88
import kotlinx.coroutines.*
99

10-
fun main(args: Array<String>) = runBlocking {
10+
fun main() = runBlocking {
11+
//sampleStart
1112
GlobalScope.launch {
1213
repeat(1000) { i ->
1314
println("I'm sleeping $i ...")
1415
delay(500L)
1516
}
1617
}
1718
delay(1300L) // just quit after delay
19+
//sampleEnd
1820
}

core/kotlinx-coroutines-core/test/guide/example-cancel-01.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ package kotlinx.coroutines.guide.cancel01
77

88
import kotlinx.coroutines.*
99

10-
fun main(args: Array<String>) = runBlocking {
10+
fun main() = runBlocking {
11+
//sampleStart
1112
val job = launch {
1213
repeat(1000) { i ->
1314
println("I'm sleeping $i ...")
@@ -19,4 +20,5 @@ fun main(args: Array<String>) = runBlocking {
1920
job.cancel() // cancels the job
2021
job.join() // waits for job's completion
2122
println("main: Now I can quit.")
23+
//sampleEnd
2224
}

0 commit comments

Comments
 (0)