Skip to main content

Module runtime

Module runtime 

Source
Expand description

Tokio runtime ownership.

Kerniq never creates a runtime behind the user’s back. There are exactly two modes:

  • User-managed (app.run(addr).await): the application owns the runtime, typically through #[tokio::main]. Kerniq only spawns tasks on it.
  • Framework-managed (app.run_blocking(addr)): Kerniq builds a multi-threaded runtime, runs the server to completion and shuts the runtime down. This is refused with ServerError::NestedRuntime when called from inside an existing runtime, because Tokio cannot nest runtimes (it would panic).

Functions§

block_on
Builds a multi-threaded runtime, drives future to completion and shuts the runtime down, waiting at most shutdown_timeout for stray tasks.
in_runtime
Whether the current thread is inside a Tokio runtime context.