SuspendApp
fun SuspendApp(context: CoroutineContext = Dispatchers.Default, uncaught: (Throwable) -> Unit = Throwable::printStackTrace, timeout: Duration = Duration.INFINITE, block: suspend SuspendAppScope.() -> Unit)
An unsafe blocking edge that wires the SuspendAppScope (and structured concurrency) to the SuspendApp, such that the SuspendAppScope gets cancelled when the App is requested to gracefully shutdown. =>SIGTERM&SIGINT on Native & NodeJS and a ShutdownHook for JVM.
It applies backpressure to the process such that they can gracefully shutdown.
Parameters
context
the CoroutineContext where block will execute. Use EmptyCoroutineContext to create an CoroutineDispatcher for the main thread and run there instead.
timeout
the maximum backpressure time that can be applied to the process. This emulates a SIGKILL command, and after the timeout is passed the App will forcefully shut down regardless of finalizers.
block
the lambda of the actual application.