Skip to content

Commit 596187e

Browse files
Inegoelizarov
authored andcommitted
Fix more typos
1 parent 39f92ca commit 596187e

File tree

5 files changed

+32
-31
lines changed

5 files changed

+32
-31
lines changed

docs/basics.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ World!
119119
-->
120120

121121
The result is the same, but this code uses only non-blocking [delay].
122-
The main thread, that invokes `runBlocking`, _blocks_ until the coroutine inside `runBlocking` completes.
122+
The main thread invoking `runBlocking` _blocks_ until the coroutine inside `runBlocking` completes.
123123

124124
This example can be also rewritten in a more idiomatic way, using `runBlocking` to wrap
125125
the execution of the main function:
@@ -151,7 +151,7 @@ World!
151151
Here `runBlocking<Unit> { ... }` works as an adaptor that is used to start the top-level main coroutine.
152152
We explicitly specify its `Unit` return type, because a well-formed `main` function in Kotlin has to return `Unit`.
153153

154-
This is also a way to write unit-tests for suspending functions:
154+
This is also a way to write unit tests for suspending functions:
155155

156156
<!--- INCLUDE
157157
import kotlinx.coroutines.*
@@ -209,11 +209,11 @@ the background job in any way. Much better.
209209
### Structured concurrency
210210

211211
There is still something to be desired for practical usage of coroutines.
212-
When we use `GlobalScope.launch` we create a top-level coroutine. Even though it is light-weight, it still
212+
When we use `GlobalScope.launch`, we create a top-level coroutine. Even though it is light-weight, it still
213213
consumes some memory resources while it runs. If we forget to keep a reference to the newly launched
214214
coroutine it still runs. What if the code in the coroutine hangs (for example, we erroneously
215215
delay for too long), what if we launched too many coroutines and ran out of memory?
216-
Having to manually keep a reference to all the launched coroutines and [join][Job.join] them is error-prone.
216+
Having to manually keep references to all the launched coroutines and [join][Job.join] them is error-prone.
217217

218218
There is a better solution. We can use structured concurrency in our code.
219219
Instead of launching coroutines in the [GlobalScope], just like we usually do with threads (threads are always global),

kotlinx-coroutines-core/common/src/Builders.common.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ import kotlin.jvm.*
1818
// --------------- launch ---------------
1919

2020
/**
21-
* Launches new coroutine without blocking current thread and returns a reference to the coroutine as a [Job].
21+
* Launches a new coroutine without blocking the current thread and returns a reference to the coroutine as a [Job].
2222
* The coroutine is cancelled when the resulting job is [cancelled][Job.cancel].
2323
*
24-
* Coroutine context is inherited from a [CoroutineScope], additional context elements can be specified with [context] argument.
24+
* The coroutine context is inherited from a [CoroutineScope]. Additional context elements can be specified with [context] argument.
2525
* If the context does not have any dispatcher nor any other [ContinuationInterceptor], then [Dispatchers.Default] is used.
2626
* The parent job is inherited from a [CoroutineScope] as well, but it can also be overridden
27-
* with corresponding [coroutineContext] element.
27+
* with a corresponding [coroutineContext] element.
2828
*
2929
* By default, the coroutine is immediately scheduled for execution.
3030
* Other start options can be specified via `start` parameter. See [CoroutineStart] for details.

kotlinx-coroutines-core/common/src/CoroutineScope.kt

+12-12
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public val CoroutineScope.isActive: Boolean
116116
* and are not cancelled prematurely.
117117
* Another use of the global scope is operators running in [Dispatchers.Unconfined], which don't have any job associated with them.
118118
*
119-
* Application code usually should use application-defined [CoroutineScope], using
119+
* Application code usually should use an application-defined [CoroutineScope]. Using
120120
* [async][CoroutineScope.async] or [launch][CoroutineScope.launch]
121121
* on the instance of [GlobalScope] is highly discouraged.
122122
*
@@ -140,14 +140,14 @@ public object GlobalScope : CoroutineScope {
140140
}
141141

142142
/**
143-
* Creates new [CoroutineScope] and calls the specified suspend block with this scope.
143+
* Creates a [CoroutineScope] and calls the specified suspend block with this scope.
144144
* The provided scope inherits its [coroutineContext][CoroutineScope.coroutineContext] from the outer scope, but overrides
145-
* context's [Job].
145+
* the context's [Job].
146146
*
147-
* This function is designed for a _parallel decomposition_ of work. When any child coroutine in this scope fails,
147+
* This function is designed for _parallel decomposition_ of work. When any child coroutine in this scope fails,
148148
* this scope fails and all the rest of the children are cancelled (for a different behavior see [supervisorScope]).
149-
* This function returns as soon as given block and all its children coroutines are completed.
150-
* Example of the scope usages looks like this:
149+
* This function returns as soon as the given block and all its children coroutines are completed.
150+
* A usage example of a scope looks like this:
151151
*
152152
* ```
153153
* suspend fun showSomeData() = coroutineScope {
@@ -166,12 +166,12 @@ public object GlobalScope : CoroutineScope {
166166
*
167167
* Semantics of the scope in this example:
168168
* 1) `showSomeData` returns as soon as data is loaded and displayed in the UI.
169-
* 2) If `doSomeWork` throws an exception, then `async` task is cancelled and `showSomeData` rethrows that exception.
170-
* 3) If outer scope of `showSomeData` is cancelled, both started `async` and `withContext` blocks are cancelled.
171-
* 4) If `async` block fails, `withContext` will be cancelled.
169+
* 2) If `doSomeWork` throws an exception, then the `async` task is cancelled and `showSomeData` rethrows that exception.
170+
* 3) If the outer scope of `showSomeData` is cancelled, both started `async` and `withContext` blocks are cancelled.
171+
* 4) If the `async` block fails, `withContext` will be cancelled.
172172
*
173-
* Method may throw [CancellationException] if the current job was cancelled externally
174-
* or may throw the corresponding unhandled [Throwable] if there is any unhandled exception in this scope
173+
* The method may throw a [CancellationException] if the current job was cancelled externally
174+
* or may throw a corresponding unhandled [Throwable] if there is any unhandled exception in this scope
175175
* (for example, from a crashed coroutine that was started with [launch][CoroutineScope.launch] in this scope).
176176
*/
177177
public suspend fun <R> coroutineScope(block: suspend CoroutineScope.() -> R): R =
@@ -181,7 +181,7 @@ public suspend fun <R> coroutineScope(block: suspend CoroutineScope.() -> R): R
181181
}
182182

183183
/**
184-
* Creates [CoroutineScope] that wraps the given coroutine [context].
184+
* Creates a [CoroutineScope] that wraps the given coroutine [context].
185185
*
186186
* If the given [context] does not contain a [Job] element, then a default `Job()` is created.
187187
* This way, cancellation or failure or any child coroutine in this scope cancels all the other children,

kotlinx-coroutines-core/common/src/Job.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public interface Job : CoroutineContext.Element {
158158
/**
159159
* Cancels this job with an optional cancellation [cause].
160160
* A cause can be used to specify an error message or to provide other details on
161-
* a cancellation reason for debugging purposes.
161+
* the cancellation reason for debugging purposes.
162162
* See [Job] documentation for full explanation of cancellation machinery.
163163
*/
164164
public fun cancel(cause: CancellationException? = null)
@@ -223,23 +223,23 @@ public interface Job : CoroutineContext.Element {
223223
// ------------ state waiting ------------
224224

225225
/**
226-
* Suspends coroutine until this job is complete. This invocation resumes normally (without exception)
226+
* Suspends the coroutine until this job is complete. This invocation resumes normally (without exception)
227227
* when the job is complete for any reason and the [Job] of the invoking coroutine is still [active][isActive].
228228
* This function also [starts][Job.start] the corresponding coroutine if the [Job] was still in _new_ state.
229229
*
230230
* Note that the job becomes complete only when all its children are complete.
231231
*
232-
* This suspending function is cancellable and **always** checks for the cancellation of invoking coroutine's Job.
232+
* This suspending function is cancellable and **always** checks for a cancellation of the invoking coroutine's Job.
233233
* If the [Job] of the invoking coroutine is cancelled or completed when this
234234
* suspending function is invoked or while it is suspended, this function
235235
* throws [CancellationException].
236236
*
237237
* In particular, it means that a parent coroutine invoking `join` on a child coroutine that was started using
238238
* `launch(coroutineContext) { ... }` builder throws [CancellationException] if the child
239-
* had crashed, unless a non-standard [CoroutineExceptionHandler] if installed in the context.
239+
* had crashed, unless a non-standard [CoroutineExceptionHandler] is installed in the context.
240240
*
241241
* This function can be used in [select] invocation with [onJoin] clause.
242-
* Use [isCompleted] to check for completion of this job without waiting.
242+
* Use [isCompleted] to check for a completion of this job without waiting.
243243
*
244244
* There is [cancelAndJoin] function that combines an invocation of [cancel] and `join`.
245245
*/
@@ -462,9 +462,9 @@ internal fun Job.disposeOnCompletion(handle: DisposableHandle): DisposableHandle
462462
invokeOnCompletion(handler = DisposeOnCompletion(this, handle).asHandler)
463463

464464
/**
465-
* Cancels the job and suspends invoking coroutine until the cancelled job is complete.
465+
* Cancels the job and suspends the invoking coroutine until the cancelled job is complete.
466466
*
467-
* This suspending function is cancellable and **always** checks for the cancellation of invoking coroutine's Job.
467+
* This suspending function is cancellable and **always** checks for a cancellation of the invoking coroutine's Job.
468468
* If the [Job] of the invoking coroutine is cancelled or completed when this
469469
* suspending function is invoked or while it is suspended, this function
470470
* throws [CancellationException].

kotlinx-coroutines-core/jvm/src/Builders.kt

+6-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import java.util.concurrent.locks.*
1111
import kotlin.coroutines.*
1212

1313
/**
14-
* Runs new coroutine and **blocks** current thread _interruptibly_ until its completion.
15-
* This function should not be used from coroutine. It is designed to bridge regular blocking code
14+
* Runs a new coroutine and **blocks** the current thread _interruptibly_ until its completion.
15+
* This function should not be used from a coroutine. It is designed to bridge regular blocking code
1616
* to libraries that are written in suspending style, to be used in `main` functions and in tests.
1717
*
1818
* The default [CoroutineDispatcher] for this builder is an internal implementation of event loop that processes continuations
@@ -21,14 +21,15 @@ import kotlin.coroutines.*
2121
*
2222
* When [CoroutineDispatcher] is explicitly specified in the [context], then the new coroutine runs in the context of
2323
* the specified dispatcher while the current thread is blocked. If the specified dispatcher is an event loop of another `runBlocking`,
24-
* then this invocation uses an outer event loop.
24+
* then this invocation uses the outer event loop.
2525
*
2626
* If this blocked thread is interrupted (see [Thread.interrupt]), then the coroutine job is cancelled and
2727
* this `runBlocking` invocation throws [InterruptedException].
2828
*
29-
* See [newCoroutineContext][CoroutineScope.newCoroutineContext] for a description of debugging facilities that are available for newly created coroutine.
29+
* See [newCoroutineContext][CoroutineScope.newCoroutineContext] for a description of debugging facilities that are available
30+
* for a newly created coroutine.
3031
*
31-
* @param context context of the coroutine. The default value is an event loop on current thread.
32+
* @param context the context of the coroutine. The default value is an event loop on the current thread.
3233
* @param block the coroutine code.
3334
*/
3435
@Throws(InterruptedException::class)

0 commit comments

Comments
 (0)