Skip to main content

Crate level_runtime

Crate level_runtime 

Source
Expand description

A per-thread runtime wrapper for Tokio

A level runtime is a multi-thread Tokio configuration, but each thread is its own local runtime. It’s mostly for servers.

Use spawn_balanced() to spawn a task on any thread. Load balancing the tasks across the runtimes is done via best-of-two random choices.

Use spawn_local() to spawn a task on this thread, with the concurrency tracking intact. Avoid tokio::spawn, as that interferes with the load leveling heuristic.

Use spawn_on_each() to spawn multiple copies of a task, one per worker thread.

Structs§

Builder
A setup builder for your level runtime.
LevelRuntime
A wrapper for a collection of tokio current-thread runtimes.
LevelRuntimeHandle
A handle to a LevelRuntime for spawning tasks.
LevelWorker
A thread-local runtime wrapper
LevelWorkerHandle
A spawn handle for the local runtime

Functions§

spawn_balanced
Spawn a task on one of the local runtimes, with a work balance heuristic.
spawn_local
Spawn this future on this local thread runtime.
spawn_on_each
Spawn a copy of a task on each local runtime.