Skip to content

Commit 5ea018c

Browse files
authored
Set the event loop whenever DefaultExecutor is accessed
Before, the event loop was only set when a non-delayed action was being scheduled. Fixes #4239
1 parent 58f880e commit 5ea018c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kotlinx-coroutines-core/wasmWasi/src/EventLoop.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,19 @@ private fun sleep(nanos: Long, ptrTo32Bytes: Pointer, ptrTo8Bytes: Pointer, ptrT
3939
}
4040

4141
internal actual object DefaultExecutor : EventLoopImplBase() {
42+
43+
init {
44+
if (kotlin.wasm.internal.onExportedFunctionExit == null) {
45+
kotlin.wasm.internal.onExportedFunctionExit = ::runEventLoop
46+
}
47+
}
48+
4249
override fun shutdown() {
4350
// don't do anything: on WASI, the event loop is the default executor, we can't shut it down
4451
}
4552

4653
override fun invokeOnTimeout(timeMillis: Long, block: Runnable, context: CoroutineContext): DisposableHandle =
4754
scheduleInvokeOnTimeout(timeMillis, block)
48-
49-
actual override fun enqueue(task: Runnable) {
50-
if (kotlin.wasm.internal.onExportedFunctionExit == null) {
51-
kotlin.wasm.internal.onExportedFunctionExit = ::runEventLoop
52-
}
53-
super.enqueue(task)
54-
}
5555
}
5656

5757
internal actual abstract class EventLoopImplPlatform : EventLoop() {

0 commit comments

Comments
 (0)