Skip to content

Commit a3f2491

Browse files
authored
Explicitly describe undispatched behaviour in runInterruptible (#3139)
Addresses #3109
1 parent 881cf68 commit a3f2491

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import kotlinx.atomicfu.*
88
import kotlin.coroutines.*
99

1010
/**
11-
* Calls the specified [block] with a given coroutine context in a interruptible manner.
11+
* Calls the specified [block] with a given coroutine context in an interruptible manner.
1212
* The blocking code block will be interrupted and this function will throw [CancellationException]
1313
* if the coroutine is cancelled.
1414
*
@@ -30,6 +30,11 @@ import kotlin.coroutines.*
3030
* suspend fun <T> BlockingQueue<T>.awaitTake(): T =
3131
* runInterruptible(Dispatchers.IO) { queue.take() }
3232
* ```
33+
*
34+
* `runInterruptible` uses [withContext] as an underlying mechanism for switching context,
35+
* meaning that the supplied [block] is invoked in an [undispatched][CoroutineStart.UNDISPATCHED]
36+
* manner directly by the caller if [CoroutineDispatcher] from the current [coroutineContext][currentCoroutineContext]
37+
* is the same as the one supplied in [context].
3338
*/
3439
public suspend fun <T> runInterruptible(
3540
context: CoroutineContext = EmptyCoroutineContext,

0 commit comments

Comments
 (0)