Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the event loop whenever DefaultExecutor is accessed #4240

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions kotlinx-coroutines-core/wasmWasi/src/EventLoop.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ private fun sleep(nanos: Long, ptrTo32Bytes: Pointer, ptrTo8Bytes: Pointer, ptrT
}

internal actual object DefaultExecutor : EventLoopImplBase() {

init {
if (kotlin.wasm.internal.onExportedFunctionExit == null) {
kotlin.wasm.internal.onExportedFunctionExit = ::runEventLoop
}
}

override fun shutdown() {
// don't do anything: on WASI, the event loop is the default executor, we can't shut it down
}

override fun invokeOnTimeout(timeMillis: Long, block: Runnable, context: CoroutineContext): DisposableHandle =
scheduleInvokeOnTimeout(timeMillis, block)

actual override fun enqueue(task: Runnable) {
if (kotlin.wasm.internal.onExportedFunctionExit == null) {
kotlin.wasm.internal.onExportedFunctionExit = ::runEventLoop
}
super.enqueue(task)
}
}

internal actual abstract class EventLoopImplPlatform : EventLoop() {
Expand Down