kotest-core / io.kotest.core.runtime / ExecutionContext

ExecutionContext

interface ExecutionContext

Abstracts the execution of functions. To be used when we want to ensure that multiple functions are executed in the same thread, but we cannot control the threading directly in the common lib.

Functions

execute

abstract suspend fun <T> execute(f: suspend () -> T): Try<T>

executeWithTimeoutInterruption

abstract suspend fun <T> executeWithTimeoutInterruption(timeout: Duration, f: suspend () -> T): T

Inheritors

CallingThreadExecutionContext

Implementation of ExecutionContext to be used in environments which do not provide the ability to spawn threads, such as Javascript. All executions occur on the same thread as the caller. This means we cannot detect a deadlock in a test as we can on the JVM by running the test in a seperate thread.

object CallingThreadExecutionContext : ExecutionContext

ExecutorExecutionContext

class ExecutorExecutionContext : ExecutionContext