Skip to content

Commit 73f153d

Browse files
Enable lazier initialization of Dispatchers.IO (#4166)
Currently, any reference to Dispatchers class, including many calls to Dispatchers.Default, force Dispatchers.IO to be initialized. This incurs several system property reads and other expensive operations even if Dispatchers.IO is never used. This PR changes this by delaying Dispatchers.IO initialization until it's first accessed.
1 parent 2397ffc commit 73f153d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public actual object Dispatchers {
6262
* during operations over IO dispatcher.
6363
*/
6464
@JvmStatic
65-
public val IO: CoroutineDispatcher = DefaultIoScheduler
65+
public val IO: CoroutineDispatcher get() = DefaultIoScheduler
6666

6767
/**
6868
* Shuts down built-in dispatchers, such as [Default] and [IO],

0 commit comments

Comments
 (0)