File tree Expand file tree Collapse file tree 4 files changed +13
-4
lines changed
main/kotlin/kotlinx/coroutines/experimental
test/kotlin/kotlinx/coroutines/experimental Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ Coroutine dispatchers implementing [CoroutineDispatcher]:
1919| [ CommonPool] | Confines coroutine execution to a shared pool of threads
2020| [ newSingleThreadContext] | Create new single-threaded coroutine context
2121| [ newFixedThreadPoolContext] | Creates new thread pool of a fixed size
22- | [ Executor.toCoroutineDispatcher ] [ java.util.concurrent.Executor.toCoroutineDispatcher ] | Extension to convert any executor
22+ | [ Executor.asCoroutineDispatcher ] [ java.util.concurrent.Executor.asCoroutineDispatcher ] | Extension to convert any executor
2323| [ Unconfined] | Does not confine coroutine execution in any way
2424
2525Synchronization primitives for coroutines:
@@ -86,7 +86,7 @@ Select expression to perform multiple suspending operations simultaneously until
8686[ CommonPool ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-common-pool/index.html
8787[ newSingleThreadContext ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/new-single-thread-context.html
8888[ newFixedThreadPoolContext ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/new-fixed-thread-pool-context.html
89- [ java.util.concurrent.Executor.toCoroutineDispatcher ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/java.util.concurrent.-executor/to -coroutine-dispatcher.html
89+ [ java.util.concurrent.Executor.asCoroutineDispatcher ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/java.util.concurrent.-executor/as -coroutine-dispatcher.html
9090[ Unconfined ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-unconfined/index.html
9191[ delay ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/delay.html
9292[ yield ] : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/yield.html
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ import kotlin.coroutines.experimental.CoroutineContext
3434 * a common pool of shared background threads.
3535 * This is an appropriate choice for compute-intensive coroutines that consume a lot of CPU resources.
3636 * * Private thread pools can be created with [newSingleThreadContext] and [newFixedThreadPoolContext].
37- * * An arbitrary [Executor][java.util.concurrent.Executor] can be converted to dispatcher with [toCoroutineDispatcher ] extension function.
37+ * * An arbitrary [Executor][java.util.concurrent.Executor] can be converted to dispatcher with [asCoroutineDispatcher ] extension function.
3838 *
3939 * This class ensures that debugging facilities in [newCoroutineContext] function work properly.
4040 */
Original file line number Diff line number Diff line change @@ -24,10 +24,19 @@ import kotlin.coroutines.experimental.CoroutineContext
2424
2525/* *
2626 * Converts an instance of [Executor] to an implementation of [CoroutineDispatcher].
27+ * @suppress **Deprecated**: Renamed to [asCoroutineDispatcher].
2728 */
29+ @Deprecated(" Renamed to `asCoroutineDispatcher`" ,
30+ replaceWith = ReplaceWith (" asCoroutineDispatcher()" ))
2831public fun Executor.toCoroutineDispatcher (): CoroutineDispatcher =
2932 ExecutorCoroutineDispatcher (this )
3033
34+ /* *
35+ * Converts an instance of [Executor] to an implementation of [CoroutineDispatcher].
36+ */
37+ public fun Executor.asCoroutineDispatcher (): CoroutineDispatcher =
38+ ExecutorCoroutineDispatcher (this )
39+
3140internal open class ExecutorCoroutineDispatcher (
3241 private val executor : Executor
3342) : CoroutineDispatcher(), Delay {
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ class ExecutorsTest {
7878 @Test
7979 fun testToExecutor () {
8080 val executor = Executors .newSingleThreadExecutor { r -> Thread (r, " TestExecutor" ) }
81- runBlocking(executor.toCoroutineDispatcher ()) {
81+ runBlocking(executor.asCoroutineDispatcher ()) {
8282 checkThreadName(" TestExecutor" )
8383 }
8484 executor.shutdown()
You can’t perform that action at this time.
0 commit comments