Skip to content

Commit 96de301

Browse files
authored
Simplify newFixedThreadPoolContext using apply and remove unused import (#4378)
* Simplify newFixedThreadPoolContext using apply * Remove unused import from Dispatchers
1 parent 3f3f4f7 commit 96de301

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

Diff for: kotlinx-coroutines-core/jvm/src/Dispatchers.kt

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package kotlinx.coroutines
22

33
import kotlinx.coroutines.internal.*
44
import kotlinx.coroutines.scheduling.*
5-
import kotlin.coroutines.*
65

76
/**
87
* Name of the property that defines the maximal number of threads that are used by [Dispatchers.IO] coroutines dispatcher.

Diff for: kotlinx-coroutines-core/jvm/src/ThreadPoolDispatcher.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ public actual fun newFixedThreadPoolContext(nThreads: Int, name: String): Execut
1010
require(nThreads >= 1) { "Expected at least one thread, but $nThreads specified" }
1111
val threadNo = AtomicInteger()
1212
val executor = Executors.newScheduledThreadPool(nThreads) { runnable ->
13-
val t = Thread(runnable, if (nThreads == 1) name else name + "-" + threadNo.incrementAndGet())
14-
t.isDaemon = true
15-
t
13+
Thread(runnable, if (nThreads == 1) name else name + "-" + threadNo.incrementAndGet())
14+
.apply { isDaemon = true }
1615
}
1716
return Executors.unconfigurableExecutorService(executor).asCoroutineDispatcher()
1817
}

0 commit comments

Comments
 (0)