ktor-server-host-common / io.ktor.server.engine / kotlinx.coroutines.Job

Extensions for kotlinx.coroutines.Job

launchOnCancellation

fun Job.launchOnCancellation(block: suspend () -> Unit): CompletableJob

Launch a coroutine with block body when the parent job is cancelled or a returned deferred is cancelled. It is important to complete or cancel returned deferred otherwise the parent job will be unable to complete successfully.