Skip to content

Commit 9304d60

Browse files
author
Francesco Vasco
committed
Release block on LazyStandaloneCoroutine start
1 parent 0b886a3 commit 9304d60

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

common/kotlinx-coroutines-core-common/src/Builders.common.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,13 @@ private open class StandaloneCoroutine(
161161

162162
private class LazyStandaloneCoroutine(
163163
parentContext: CoroutineContext,
164-
private val block: suspend CoroutineScope.() -> Unit
164+
block: suspend CoroutineScope.() -> Unit
165165
) : StandaloneCoroutine(parentContext, active = false) {
166+
private var block: (suspend CoroutineScope.() -> Unit)? = block
167+
166168
override fun onStart() {
169+
val block = checkNotNull(this.block) { "Already started" }
170+
this.block = null
167171
block.startCoroutineCancellable(this, this)
168172
}
169173
}

0 commit comments

Comments
 (0)