Skip to content

Commit 8140cfe

Browse files
Inegoqwwdfsad
authored andcommitted
Fix typos and improve article usage in docs
1 parent 827e5e3 commit 8140cfe

16 files changed

+72
-72
lines changed

docs/cancellation-and-timeouts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ This section covers coroutine cancellation and timeouts.
3838
In a long-running application you might need fine-grained control on your background coroutines.
3939
For example, a user might have closed the page that launched a coroutine and now its result
4040
is no longer needed and its operation can be cancelled.
41-
The [launch] function returns a [Job] that can be used to cancel running coroutine:
41+
The [launch] function returns a [Job] that can be used to cancel the running coroutine:
4242

4343
<div class="sample" markdown="1" theme="idea" data-min-compiler-version="1.3">
4444

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,44 @@ import kotlin.jvm.*
2020
*
2121
* The following methods are available for override:
2222
*
23-
* * [onStart] is invoked when coroutine was created in not active state and is being [started][Job.start].
24-
* * [onCancelling] is invoked as soon as coroutine is being cancelled for any reason (or completes).
25-
* * [onCompleted] is invoked when coroutine completes with a value.
26-
* * [onCancelled] in invoked when coroutines completes with exception (cancelled).
23+
* * [onStart] is invoked when the coroutine was created in non-active state and is being [started][Job.start].
24+
* * [onCancelling] is invoked as soon as the coroutine starts being cancelled for any reason (or completes).
25+
* * [onCompleted] is invoked when the coroutine completes with a value.
26+
* * [onCancelled] in invoked when the coroutine completes with an exception (cancelled).
2727
*
28-
* @param parentContext context of the parent coroutine.
29-
* @param active when `true` (by default) coroutine is created in _active_ state, when `false` in _new_ state.
28+
* @param parentContext the context of the parent coroutine.
29+
* @param active when `true` (by default), the coroutine is created in the _active_ state, otherwise it is created in the _new_ state.
3030
* See [Job] for details.
3131
*
3232
* @suppress **This an internal API and should not be used from general code.**
3333
*/
3434
@InternalCoroutinesApi
3535
public abstract class AbstractCoroutine<in T>(
3636
/**
37-
* Context of the parent coroutine.
37+
* The context of the parent coroutine.
3838
*/
3939
@JvmField
4040
protected val parentContext: CoroutineContext,
4141
active: Boolean = true
4242
) : JobSupport(active), Job, Continuation<T>, CoroutineScope {
4343
/**
44-
* Context of this coroutine that includes this coroutine as a [Job].
44+
* The context of this coroutine that includes this coroutine as a [Job].
4545
*/
4646
@Suppress("LeakingThis")
4747
public final override val context: CoroutineContext = parentContext + this
4848

4949
/**
50-
* Context of this scope which is the same as the [context] of this coroutine.
50+
* The context of this scope which is the same as the [context] of this coroutine.
5151
*/
5252
public override val coroutineContext: CoroutineContext get() = context
5353

5454
override val isActive: Boolean get() = super.isActive
5555

5656
/**
57-
* Initializes parent job from the `parentContext` of this coroutine that was passed to it during construction.
57+
* Initializes the parent job from the `parentContext` of this coroutine that was passed to it during construction.
5858
* It shall be invoked at most once after construction after all other initialization.
5959
*
60-
* Invocation of this function may cause this coroutine to become cancelled if parent is already cancelled,
60+
* Invocation of this function may cause this coroutine to become cancelled if the parent is already cancelled,
6161
* in which case it synchronously invokes all the corresponding handlers.
6262
* @suppress **This is unstable API and it is subject to change.**
6363
*/
@@ -66,7 +66,7 @@ public abstract class AbstractCoroutine<in T>(
6666
}
6767

6868
/**
69-
* This function is invoked once when non-active coroutine (constructed with `active` set to `false)
69+
* This function is invoked once when a non-active coroutine (constructed with `active` set to `false)
7070
* is [started][start].
7171
*/
7272
protected open fun onStart() {}
@@ -76,13 +76,13 @@ public abstract class AbstractCoroutine<in T>(
7676
}
7777

7878
/**
79-
* This function is invoked once when job was completed normally with the specified [value],
80-
* right before all the waiters for coroutine's completion are notified.
79+
* This function is invoked once when the job was completed normally with the specified [value],
80+
* right before all the waiters for the coroutine's completion are notified.
8181
*/
8282
protected open fun onCompleted(value: T) {}
8383

8484
/**
85-
* This function is invoked once when job was cancelled with the specified [cause],
85+
* This function is invoked once when the job was cancelled with the specified [cause],
8686
* right before all the waiters for coroutine's completion are notified.
8787
*
8888
* **Note:** the state of the coroutine might not be final yet in this function and should not be queried.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import kotlinx.coroutines.selects.*
1010
/**
1111
* A [Deferred] that can be completed via public functions [complete] or [cancel][Job.cancel].
1212
*
13-
* Note that [complete] functions returns `false` when this deferred value is already complete or completing,
14-
* while [cancel][Job.cancel] returns `true` as long the deferred is still _cancelling_ and the corresponding
13+
* Note that the [complete] function returns `false` when this deferred value is already complete or completing,
14+
* while [cancel][Job.cancel] returns `true` as long as the deferred is still _cancelling_ and the corresponding
1515
* exception is incorporated into the final [completion exception][getCompletionExceptionOrNull].
1616
*
1717
* An instance of completable deferred can be created by `CompletableDeferred()` function in _active_ state.
@@ -24,7 +24,7 @@ public interface CompletableDeferred<T> : Deferred<T> {
2424
* Completes this deferred value with a given [value]. The result is `true` if this deferred was
2525
* completed as a result of this invocation and `false` otherwise (if it was already completed).
2626
*
27-
* Repeated invocations of this function have no effect and always produce `false`.
27+
* Subsequent invocations of this function have no effect and always produce `false`.
2828
*
2929
* This function transitions this deferred into _completed_ state if it was not completed or cancelled yet.
3030
* However, if this deferred has children, then it transitions into _completing_ state and becomes _complete_
@@ -36,7 +36,7 @@ public interface CompletableDeferred<T> : Deferred<T> {
3636
* Completes this deferred value exceptionally with a given [exception]. The result is `true` if this deferred was
3737
* completed as a result of this invocation and `false` otherwise (if it was already completed).
3838
*
39-
* Repeated invocations of this function have no effect and always produce `false`.
39+
* Subsequent invocations of this function have no effect and always produce `false`.
4040
*
4141
* This function transitions this deferred into _cancelled_ state if it was not completed or cancelled yet.
4242
* However, that if this deferred has children, then it transitions into _cancelling_ state and becomes _cancelled_

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public interface CompletableJob : Job {
1313
* Completes this job. The result is `true` if this job was completed as a result of this invocation and
1414
* `false` otherwise (if it was already completed).
1515
*
16-
* Repeated invocations of this function have no effect and always produce `false`.
16+
* Subsequent invocations of this function have no effect and always produce `false`.
1717
*
1818
* This function transitions this job into _completed- state if it was not completed or cancelled yet.
1919
* However, that if this job has children, then it transitions into _completing_ state and becomes _complete_
@@ -25,7 +25,7 @@ public interface CompletableJob : Job {
2525
* Completes this job exceptionally with a given [exception]. The result is `true` if this job was
2626
* completed as a result of this invocation and `false` otherwise (if it was already completed).
2727
*
28-
* Repeated invocations of this function have no effect and always produce `false`.
28+
* Subsequent invocations of this function have no effect and always produce `false`.
2929
*
3030
* This function transitions this job into _cancelled_ state if it was not completed or cancelled yet.
3131
* However, that if this job has children, then it transitions into _cancelling_ state and becomes _cancelled_

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import kotlinx.coroutines.internal.*
1313
* wrapped into [CompletionHandlerException], and rethrown, potentially causing crash of unrelated code.
1414
*
1515
* The meaning of `cause` that is passed to the handler:
16-
* * Cause is `null` when job has completed normally.
17-
* * Cause is an instance of [CancellationException] when job was cancelled _normally_.
16+
* * Cause is `null` when the job has completed normally.
17+
* * Cause is an instance of [CancellationException] when the job was cancelled _normally_.
1818
* **It should not be treated as an error**. In particular, it should not be reported to error logs.
1919
* * Otherwise, the job had _failed_.
2020
*

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal expect fun handleCoroutineExceptionImpl(context: CoroutineContext, exce
1919
*/
2020
@InternalCoroutinesApi
2121
public fun handleCoroutineException(context: CoroutineContext, exception: Throwable) {
22-
// Invoke exception handler from the context if present
22+
// Invoke an exception handler from the context if present
2323
try {
2424
context[CoroutineExceptionHandler]?.let {
2525
it.handleException(context, exception)
@@ -29,7 +29,7 @@ public fun handleCoroutineException(context: CoroutineContext, exception: Throwa
2929
handleCoroutineExceptionImpl(context, handlerException(exception, t))
3030
return
3131
}
32-
// If handler is not present in the context or exception was thrown, fallback to the global handler
32+
// If a handler is not present in the context or an exception was thrown, fallback to the global handler
3333
handleCoroutineExceptionImpl(context, exception)
3434
}
3535

@@ -54,7 +54,7 @@ public inline fun CoroutineExceptionHandler(crossinline handler: (CoroutineConte
5454
/**
5555
* An optional element in the coroutine context to handle uncaught exceptions.
5656
*
57-
* Normally, uncaught exceptions can only result from coroutines created using [launch][CoroutineScope.launch] builder.
57+
* Normally, uncaught exceptions can only result from coroutines created using the [launch][CoroutineScope.launch] builder.
5858
* A coroutine that was created using [async][CoroutineScope.async] always catches all its exceptions and represents them
5959
* in the resulting [Deferred] object.
6060
*

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import kotlin.coroutines.intrinsics.*
1515
* to automatically propagate both context elements and cancellation.
1616
*
1717
* The best ways to obtain a standalone instance of the scope are [CoroutineScope()] and [MainScope()] factory functions.
18-
* Additional context elements can be appended to the scope using [plus][CoroutineScope.plus] operator.
18+
* Additional context elements can be appended to the scope using the [plus][CoroutineScope.plus] operator.
1919
*
2020
* Manual implementation of this interface is not recommended, implementation by delegation should be preferred instead.
21-
* By convention, [context of the scope][CoroutineScope.coroutineContext] should contain an instance of a [job][Job] to enforce structured concurrency.
21+
* By convention, the [context of a scope][CoroutineScope.coroutineContext] should contain an instance of a [job][Job] to enforce structured concurrency.
2222
*
2323
* Every coroutine builder (like [launch][CoroutineScope.launch], [async][CoroutineScope.async], etc)
2424
* and every scoping function (like [coroutineScope], [withContext], etc) provides _its own_ scope
@@ -164,8 +164,8 @@ public object GlobalScope : CoroutineScope {
164164
* }
165165
* ```
166166
*
167-
* Semantics of the scope in this example:
168-
* 1) `showSomeData` returns as soon as data is loaded and displayed in the UI.
167+
* The scope in this example has the following semantics:
168+
* 1) `showSomeData` returns as soon as the data is loaded and displayed in the UI.
169169
* 2) If `doSomeWork` throws an exception, then the `async` task is cancelled and `showSomeData` rethrows that exception.
170170
* 3) If the outer scope of `showSomeData` is cancelled, both started `async` and `withContext` blocks are cancelled.
171171
* 4) If the `async` block fails, `withContext` will be cancelled.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public enum class CoroutineStart {
6060

6161
/**
6262
* Immediately executes the coroutine until its first suspension point _in the current thread_ as if the
63-
* coroutine was started using [Dispatchers.Unconfined]. However, when coroutine is resumed from suspension
63+
* coroutine was started using [Dispatchers.Unconfined]. However, when the coroutine is resumed from suspension
6464
* it is dispatched according to the [CoroutineDispatcher] in its context.
6565
*
6666
* This is similar to [ATOMIC] in the sense that coroutine starts executing even if it was already cancelled,

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ package kotlinx.coroutines
77
import kotlinx.coroutines.selects.*
88

99
/**
10-
* Deferred value is a non-blocking cancellable future &mdash; it is a [Job] that has a result.
10+
* Deferred value is a non-blocking cancellable future &mdash; it is a [Job] with a result.
1111
*
12-
* It is created with [async][CoroutineScope.async] coroutine builder or via constructor of [CompletableDeferred] class.
12+
* It is created with the [async][CoroutineScope.async] coroutine builder or via the constructor of [CompletableDeferred] class.
1313
* It is in [active][isActive] state while the value is being computed.
1414
*
15-
* Deferred value has the same state machine as the [Job] with additional convenience methods to retrieve
16-
* successful or failed result of the computation that was carried out. The result of the deferred is
15+
* `Deferred` has the same state machine as the [Job] with additional convenience methods to retrieve
16+
* the successful or failed result of the computation that was carried out. The result of the deferred is
1717
* available when it is [completed][isCompleted] and can be retrieved by [await] method, which throws
18-
* exception if the deferred had failed.
19-
* Note that a _cancelled_ deferred is also considered to be completed.
18+
* an exception if the deferred had failed.
19+
* Note that a _cancelled_ deferred is also considered as completed.
2020
* The corresponding exception can be retrieved via [getCompletionExceptionOrNull] from a completed instance of deferred.
2121
*
2222
* Usually, a deferred value is created in _active_ state (it is created and started).
23-
* However, [async][CoroutineScope.async] coroutine builder has an optional `start` parameter that creates a deferred value in _new_ state
23+
* However, the [async][CoroutineScope.async] coroutine builder has an optional `start` parameter that creates a deferred value in _new_ state
2424
* when this parameter is set to [CoroutineStart.LAZY].
2525
* Such a deferred can be be made _active_ by invoking [start], [join], or [await].
2626
*

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import kotlin.jvm.*
1919
* culminates in its completion.
2020
*
2121
* Jobs can be arranged into parent-child hierarchies where cancellation
22-
* of parent lead to an immediate cancellation of all its [children]. Failure or cancellation of a child
23-
* with an exception other than [CancellationException] immediately cancels its parent. This way, parent
22+
* of a parent leads to immediate cancellation of all its [children]. Failure or cancellation of a child
23+
* with an exception other than [CancellationException] immediately cancels its parent. This way, a parent
2424
* can [cancel] its own children (including all their children recursively) without cancelling itself.
2525
*
2626
* The most basic instances of [Job] are created with [launch][CoroutineScope.launch] coroutine builder or with a
@@ -255,13 +255,13 @@ public interface Job : CoroutineContext.Element {
255255

256256
/**
257257
* Registers handler that is **synchronously** invoked once on completion of this job.
258-
* When job is already complete, then the handler is immediately invoked
259-
* with a job's exception or cancellation cause or `null`. Otherwise, handler will be invoked once when this
258+
* When the job is already complete, then the handler is immediately invoked
259+
* with the job's exception or cancellation cause or `null`. Otherwise, the handler will be invoked once when this
260260
* job is complete.
261261
*
262262
* The meaning of `cause` that is passed to the handler:
263-
* * Cause is `null` when job has completed normally.
264-
* * Cause is an instance of [CancellationException] when job was cancelled _normally_.
263+
* * Cause is `null` when the job has completed normally.
264+
* * Cause is an instance of [CancellationException] when the job was cancelled _normally_.
265265
* **It should not be treated as an error**. In particular, it should not be reported to error logs.
266266
* * Otherwise, the job had _failed_.
267267
*
@@ -281,13 +281,13 @@ public interface Job : CoroutineContext.Element {
281281

282282
/**
283283
* Registers handler that is **synchronously** invoked once on cancellation or completion of this job.
284-
* When job was already cancelled and is completed its execution, then the handler is immediately invoked
285-
* with a job's cancellation cause or `null` unless [invokeImmediately] is set to false.
284+
* when the job was already cancelled and is completed its execution, then the handler is immediately invoked
285+
* with the job's cancellation cause or `null` unless [invokeImmediately] is set to false.
286286
* Otherwise, handler will be invoked once when this job is cancelled or is complete.
287287
*
288288
* The meaning of `cause` that is passed to the handler:
289-
* * Cause is `null` when job has completed normally.
290-
* * Cause is an instance of [CancellationException] when job was cancelled _normally_.
289+
* * Cause is `null` when the job has completed normally.
290+
* * Cause is an instance of [CancellationException] when the job was cancelled _normally_.
291291
* **It should not be treated as an error**. In particular, it should not be reported to error logs.
292292
* * Otherwise, the job had _failed_.
293293
*

0 commit comments

Comments
 (0)