Skip to content

Commit

Permalink
Fixed CoroutinesScope.ensureActive docs (#2242)
Browse files Browse the repository at this point in the history
This is leftover from #2044 fix.

Fixes #2241
  • Loading branch information
elizarov committed Sep 11, 2020
1 parent fe2fedc commit 879881e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kotlinx-coroutines-core/common/src/CoroutineScope.kt
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,19 @@ public fun CoroutineScope.cancel(message: String, cause: Throwable? = null): Uni

/**
* Ensures that current scope is [active][CoroutineScope.isActive].
* Throws [IllegalStateException] if the context does not have a job in it.
*
* If the job is no longer active, throws [CancellationException].
* If the job was cancelled, thrown exception contains the original cancellation cause.
* This function does not do anything if there is no [Job] in the scope's [coroutineContext][CoroutineScope.coroutineContext].
*
* This method is a drop-in replacement for the following code, but with more precise exception:
* ```
* if (!isActive) {
* throw CancellationException()
* }
* ```
*
* @see CoroutineContext.ensureActive
*/
public fun CoroutineScope.ensureActive(): Unit = coroutineContext.ensureActive()

Expand Down

0 comments on commit 879881e

Please sign in to comment.