Skip to content

Commit 38b5ea1

Browse files
committed
Executor.toCoroutineDispatcher is renamed to asCoroutineDispatcher
1 parent 23f864e commit 38b5ea1

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

kotlinx-coroutines-core/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

2525
Synchronization 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

kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/CoroutineDispatcher.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
*/

kotlinx-coroutines-core/src/main/kotlin/kotlinx/coroutines/experimental/Executors.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff 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()"))
2831
public 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+
3140
internal open class ExecutorCoroutineDispatcher(
3241
private val executor: Executor
3342
) : CoroutineDispatcher(), Delay {

kotlinx-coroutines-core/src/test/kotlin/kotlinx/coroutines/experimental/ExecutorsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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()

0 commit comments

Comments
 (0)