Skip to content

Commit 69c26df

Browse files
Inegoelizarov
authored andcommitted
Add a period in the "You can get full code here" blocks and other small fixes
1 parent 564a5a6 commit 69c26df

17 files changed

+108
-108
lines changed

docs/basics.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Run the following code:
4747
import kotlinx.coroutines.*
4848

4949
fun main() {
50-
GlobalScope.launch { // launch new coroutine in background and continue
50+
GlobalScope.launch { // launch a new coroutine in background and continue
5151
delay(1000L) // non-blocking delay for 1 second (default time unit is ms)
5252
println("World!") // print after delay
5353
}
@@ -58,7 +58,7 @@ fun main() {
5858

5959
</div>
6060

61-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-01.kt)
61+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-01.kt).
6262
6363
You will see the following result:
6464

@@ -98,7 +98,7 @@ Let's be explicit about blocking using [runBlocking] coroutine builder:
9898
import kotlinx.coroutines.*
9999

100100
fun main() {
101-
GlobalScope.launch { // launch new coroutine in background and continue
101+
GlobalScope.launch { // launch a new coroutine in background and continue
102102
delay(1000L)
103103
println("World!")
104104
}
@@ -111,7 +111,7 @@ fun main() {
111111

112112
</div>
113113

114-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-02.kt)
114+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-02.kt).
115115
116116
<!--- TEST
117117
Hello,
@@ -130,7 +130,7 @@ the execution of the main function:
130130
import kotlinx.coroutines.*
131131

132132
fun main() = runBlocking<Unit> { // start main coroutine
133-
GlobalScope.launch { // launch new coroutine in background and continue
133+
GlobalScope.launch { // launch a new coroutine in background and continue
134134
delay(1000L)
135135
println("World!")
136136
}
@@ -141,7 +141,7 @@ fun main() = runBlocking<Unit> { // start main coroutine
141141

142142
</div>
143143

144-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-02b.kt)
144+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-02b.kt).
145145
146146
<!--- TEST
147147
Hello,
@@ -184,7 +184,7 @@ import kotlinx.coroutines.*
184184

185185
fun main() = runBlocking {
186186
//sampleStart
187-
val job = GlobalScope.launch { // launch new coroutine and keep a reference to its Job
187+
val job = GlobalScope.launch { // launch a new coroutine and keep a reference to its Job
188188
delay(1000L)
189189
println("World!")
190190
}
@@ -196,7 +196,7 @@ fun main() = runBlocking {
196196

197197
</div>
198198

199-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-03.kt)
199+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-03.kt).
200200
201201
<!--- TEST
202202
Hello,
@@ -231,7 +231,7 @@ in its scope complete. Thus, we can make our example simpler:
231231
import kotlinx.coroutines.*
232232

233233
fun main() = runBlocking { // this: CoroutineScope
234-
launch { // launch new coroutine in the scope of runBlocking
234+
launch { // launch a new coroutine in the scope of runBlocking
235235
delay(1000L)
236236
println("World!")
237237
}
@@ -241,7 +241,7 @@ fun main() = runBlocking { // this: CoroutineScope
241241

242242
</div>
243243

244-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-03s.kt)
244+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-03s.kt).
245245
246246
<!--- TEST
247247
Hello,
@@ -272,16 +272,16 @@ fun main() = runBlocking { // this: CoroutineScope
272272
}
273273

274274
delay(100L)
275-
println("Task from coroutine scope") // This line will be printed before nested launch
275+
println("Task from coroutine scope") // This line will be printed before the nested launch
276276
}
277277

278-
println("Coroutine scope is over") // This line is not printed until nested launch completes
278+
println("Coroutine scope is over") // This line is not printed until the nested launch completes
279279
}
280280
```
281281

282282
</div>
283283

284-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-04.kt)
284+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-04.kt).
285285
286286
<!--- TEST
287287
Task from coroutine scope
@@ -317,7 +317,7 @@ suspend fun doWorld() {
317317

318318
</div>
319319

320-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-05.kt)
320+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-05.kt).
321321
322322
<!--- TEST
323323
Hello,
@@ -328,10 +328,10 @@ World!
328328
But what if the extracted function contains a coroutine builder which is invoked on the current scope?
329329
In this case `suspend` modifier on the extracted function is not enough. Making `doWorld` extension
330330
method on `CoroutineScope` is one of the solutions, but it may not always be applicable as it does not make API clearer.
331-
Idiomatic solution is to have either explicit `CoroutineScope` as a field in a class containing target function
332-
or implicit when outer class implements `CoroutineScope`.
331+
The idiomatic solution is to have either an explicit `CoroutineScope` as a field in a class containing the target function
332+
or an implicit one when the outer class implements `CoroutineScope`.
333333
As a last resort, [CoroutineScope(coroutineContext)][CoroutineScope()] can be used, but such approach is structurally unsafe
334-
because you no longer have control on the scope this method is executed. Only private API can use this builder.
334+
because you no longer have control on the scope of execution of this method. Only private APIs can use this builder.
335335

336336
### Coroutines ARE light-weight
337337

@@ -354,7 +354,7 @@ fun main() = runBlocking {
354354

355355
</div>
356356

357-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-06.kt)
357+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-06.kt).
358358
359359
<!--- TEST lines.size == 1 && lines[0] == ".".repeat(100_000) -->
360360

@@ -386,7 +386,7 @@ fun main() = runBlocking {
386386

387387
</div>
388388

389-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-07.kt)
389+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-07.kt).
390390
391391
You can run and see that it prints three lines and terminates:
392392

docs/cancellation-and-timeouts.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fun main() = runBlocking {
6464

6565
</div>
6666

67-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-01.kt)
67+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-01.kt).
6868
6969
It produces the following output:
7070

@@ -119,7 +119,7 @@ fun main() = runBlocking {
119119

120120
</div>
121121

122-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-02.kt)
122+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-02.kt).
123123
124124
Run it to see that it continues to print "I'm sleeping" even after cancellation
125125
until the job completes by itself after five iterations.
@@ -171,7 +171,7 @@ fun main() = runBlocking {
171171

172172
</div>
173173

174-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt)
174+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt).
175175
176176
As you can see, now this loop is cancelled. [isActive] is an extension property that is
177177
available inside the code of coroutine via [CoroutineScope] object.
@@ -218,7 +218,7 @@ fun main() = runBlocking {
218218

219219
</div>
220220

221-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-04.kt)
221+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-04.kt).
222222
223223
Both [join][Job.join] and [cancelAndJoin] wait for all the finalization actions to complete,
224224
so the example above produces the following output:
@@ -274,7 +274,7 @@ fun main() = runBlocking {
274274

275275
</div>
276276

277-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-05.kt)
277+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-05.kt).
278278
279279
<!--- TEST
280280
I'm sleeping 0 ...
@@ -313,7 +313,7 @@ fun main() = runBlocking {
313313

314314
</div>
315315

316-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-06.kt)
316+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-06.kt).
317317
318318
It produces the following output:
319319

@@ -357,7 +357,7 @@ fun main() = runBlocking {
357357

358358
</div>
359359

360-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-07.kt)
360+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-cancel-07.kt).
361361
362362
There is no longer an exception when running this code:
363363

docs/channels.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fun main() = runBlocking {
7171

7272
</div>
7373

74-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-01.kt)
74+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-01.kt).
7575
7676
The output of this code is:
7777

@@ -118,7 +118,7 @@ fun main() = runBlocking {
118118

119119
</div>
120120

121-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-02.kt)
121+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-02.kt).
122122
123123
<!--- TEST
124124
1
@@ -160,7 +160,7 @@ fun main() = runBlocking {
160160

161161
</div>
162162

163-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-03.kt)
163+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-03.kt).
164164
165165
<!--- TEST
166166
1
@@ -231,7 +231,7 @@ fun CoroutineScope.square(numbers: ReceiveChannel<Int>): ReceiveChannel<Int> = p
231231

232232
</div>
233233

234-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-04.kt)
234+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-04.kt).
235235
236236
<!--- TEST
237237
1
@@ -322,7 +322,7 @@ fun CoroutineScope.filter(numbers: ReceiveChannel<Int>, prime: Int) = produce<In
322322

323323
</div>
324324

325-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-05.kt)
325+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-05.kt).
326326
327327
The output of this code is:
328328

@@ -425,7 +425,7 @@ fun CoroutineScope.launchProcessor(id: Int, channel: ReceiveChannel<Int>) = laun
425425

426426
</div>
427427

428-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-06.kt)
428+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-06.kt).
429429
430430
The output will be similar to the the following one, albeit the processor ids that receive
431431
each specific integer may be different:
@@ -505,7 +505,7 @@ suspend fun sendString(channel: SendChannel<String>, s: String, time: Long) {
505505

506506
</div>
507507

508-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-07.kt)
508+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-07.kt).
509509
510510
The output is:
511511

@@ -557,7 +557,7 @@ fun main() = runBlocking<Unit> {
557557

558558
</div>
559559

560-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-08.kt)
560+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-08.kt).
561561
562562
It prints "sending" _five_ times using a buffered channel with capacity of _four_:
563563

@@ -612,7 +612,7 @@ suspend fun player(name: String, table: Channel<Ball>) {
612612

613613
</div>
614614

615-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-09.kt)
615+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-09.kt).
616616
617617
The "ping" coroutine is started first, so it is the first one to receive the ball. Even though "ping"
618618
coroutine immediately starts receiving the ball again after sending it back to the table, the ball gets
@@ -675,7 +675,7 @@ fun main() = runBlocking<Unit> {
675675

676676
</div>
677677

678-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-10.kt)
678+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-channel-10.kt).
679679
680680
It prints following lines:
681681

docs/composing-suspending-functions.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ suspend fun doSomethingUsefulTwo(): Int {
9797

9898
</div>
9999

100-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-compose-01.kt)
100+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-compose-01.kt).
101101
102102
It produces something like this:
103103

@@ -150,7 +150,7 @@ suspend fun doSomethingUsefulTwo(): Int {
150150

151151
</div>
152152

153-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-compose-02.kt)
153+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-compose-02.kt).
154154
155155
It produces something like this:
156156

@@ -204,7 +204,7 @@ suspend fun doSomethingUsefulTwo(): Int {
204204

205205
</div>
206206

207-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-compose-03.kt)
207+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-compose-03.kt).
208208
209209
It produces something like this:
210210

@@ -301,7 +301,7 @@ suspend fun doSomethingUsefulTwo(): Int {
301301

302302
</div>
303303

304-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-compose-04.kt)
304+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-compose-04.kt).
305305
306306
<!--- TEST ARBITRARY_TIME
307307
The answer is 42
@@ -377,7 +377,7 @@ suspend fun doSomethingUsefulTwo(): Int {
377377

378378
</div>
379379

380-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-compose-05.kt)
380+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-compose-05.kt).
381381
382382
We still have concurrent execution of both operations as evident from the output of the above main function:
383383

@@ -424,7 +424,7 @@ suspend fun failedConcurrentSum(): Int = coroutineScope {
424424

425425
</div>
426426

427-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-compose-06.kt)
427+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-compose-06.kt).
428428
429429
Note, how both first `async` and awaiting parent are cancelled on the one child failure:
430430
```text

0 commit comments

Comments
 (0)