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

commonMain.dev.mokkery.internal.coroutines.RunSuspension.kt Maven / Gradle / Ivy

Go to download

Mokkery is a mocking library for Kotlin Multiplatform, easy to use, boilerplate-free and compiler plugin driven.

The newest version!
package dev.mokkery.internal.coroutines

import dev.mokkery.internal.IllegalSuspensionException
import kotlin.coroutines.Continuation
import kotlin.coroutines.EmptyCoroutineContext
import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED
import kotlin.coroutines.intrinsics.startCoroutineUninterceptedOrReturn

internal fun runSuspension(block: suspend () -> Unit) {
    if (block.startCoroutineUninterceptedOrReturn(EmptyContinuation) == COROUTINE_SUSPENDED) {
        throw IllegalSuspensionException()
    }
}

private val EmptyContinuation = Continuation(EmptyCoroutineContext) { }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy