Skip to content

Commit ac153f4

Browse files
committed
~ Updated asCoroutineDispatcher docs
1 parent fe2c2e4 commit ac153f4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

+10
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,23 @@ public abstract class ExecutorCoroutineDispatcher: CoroutineDispatcher(), Closea
3838

3939
/**
4040
* Converts an instance of [ExecutorService] to an implementation of [ExecutorCoroutineDispatcher].
41+
*
42+
* Note, that if the underlying executor uses limited queues and throws [RejectedExecutionException] on
43+
* attempt to submit a task, then the [Job] of the affected task is [cancelled][Job.cancel] and the
44+
* task is submitted to the default single-threaded executor, so that the affected coroutine can cleanup its
45+
* resources and promptly complete.
4146
*/
4247
@JvmName("from") // this is for a nice Java API, see issue #255
4348
public fun ExecutorService.asCoroutineDispatcher(): ExecutorCoroutineDispatcher =
4449
ExecutorCoroutineDispatcherImpl(this)
4550

4651
/**
4752
* Converts an instance of [Executor] to an implementation of [CoroutineDispatcher].
53+
*
54+
* Note, that if the underlying executor uses limited queues and throws [RejectedExecutionException] on
55+
* attempt to submit a task, then the [Job] of the affected task is [cancelled][Job.cancel] and the
56+
* task is submitted to the default single-threaded executor, so that the affected coroutine can cleanup its
57+
* resources and promptly complete.
4858
*/
4959
@JvmName("from") // this is for a nice Java API, see issue #255
5060
public fun Executor.asCoroutineDispatcher(): CoroutineDispatcher =

0 commit comments

Comments
 (0)