All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.smallrye.reactivemessaging.runtime.kotlin.VertxDispatcher.kt Maven / Gradle / Ivy

There is a newer version: 3.15.1
Show newest version
package io.quarkus.smallrye.reactivemessaging.runtime.kotlin

import io.quarkus.arc.Arc
import io.vertx.core.Context
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineDispatcher

class VertxDispatcher(private val vertxContext: Context) : CoroutineDispatcher() {
    override fun dispatch(context: CoroutineContext, block: Runnable) {
        val requestContext = Arc.container().requestContext()
        vertxContext.runOnContext {
            if (requestContext.isActive) {
                block.run()
            } else {
                try {
                    requestContext.activate()
                    block.run()
                } finally {
                    requestContext.terminate()
                }
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy