Skip to content

Commit 85aa46d

Browse files
committed
Clarification on CompletableJob/Deferred.completeExceptionally logic
1 parent c5e4c25 commit 85aa46d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ public interface CompletableDeferred<T> : Deferred<T> {
2626
*
2727
* Repeated invocations of this function have no effect and always produce `false`.
2828
*
29-
* Note, that if this deferred has children, then it transitions into _completing_ state and becomes _complete_
30-
* once all its children are _complete_. See [Job] for details.
29+
* This function transitions this deferred into _completed_ state if it was not completed or cancelled yet.
30+
* However, if this deferred has children, then it transitions into _completing_ state and becomes _complete_
31+
* once all its children are [complete][isCompleted]. See [Job] for details.
3132
*/
3233
public fun complete(value: T): Boolean
3334

@@ -36,6 +37,10 @@ public interface CompletableDeferred<T> : Deferred<T> {
3637
* completed as a result of this invocation and `false` otherwise (if it was already completed).
3738
*
3839
* Repeated invocations of this function have no effect and always produce `false`.
40+
*
41+
* This function transitions this deferred into _cancelled_ state if it was not completed or cancelled yet.
42+
* However, that if this deferred has children, then it transitions into _cancelling_ state and becomes _cancelled_
43+
* once all its children are [complete][isCompleted]. See [Job] for details.
3944
*/
4045
public fun completeExceptionally(exception: Throwable): Boolean
4146
}

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ public interface CompletableJob : Job {
1515
*
1616
* Repeated invocations of this function have no effect and always produce `false`.
1717
*
18-
* Note, that if this job has children, then it transitions into _completing_ state and becomes _complete_
19-
* once all its children are _complete_. See [Job] for details.
18+
* This function transitions this job into _completed- state if it was not completed or cancelled yet.
19+
* However, that if this job has children, then it transitions into _completing_ state and becomes _complete_
20+
* once all its children are [complete][isCompleted]. See [Job] for details.
2021
*/
2122
public fun complete(): Boolean
2223

@@ -25,6 +26,10 @@ public interface CompletableJob : Job {
2526
* completed as a result of this invocation and `false` otherwise (if it was already completed).
2627
*
2728
* Repeated invocations of this function have no effect and always produce `false`.
29+
*
30+
* This function transitions this job into _cancelled_ state if it was not completed or cancelled yet.
31+
* However, that if this job has children, then it transitions into _cancelling_ state and becomes _cancelled_
32+
* once all its children are [complete][isCompleted]. See [Job] for details.
2833
*/
2934
public fun completeExceptionally(exception: Throwable): Boolean
3035
}

0 commit comments

Comments
 (0)