level_runtime/lib.rs
1#![deny(missing_docs)]
2//! A per-thread runtime wrapper for Tokio
3//!
4//! A level runtime is a multi-thread Tokio configuration,
5//! but each thread is its own local runtime. It's mostly
6//! for servers.
7//!
8//! Use `spawn_balanced()` to spawn a task on any thread.
9//! Load balancing the tasks across the runtimes is done via
10//! best-of-two random choices.
11//!
12//! Use `spawn_local()` to spawn a task on _this_ thread, with
13//! the concurrency tracking intact. Avoid `tokio::spawn`, as
14//! that interferes with the load leveling heuristic.
15//!
16//! Use `spawn_on_each()` to spawn multiple copies of a task,
17//! one per worker thread.
18
19mod builder;
20mod concurrency_tracker;
21mod runtime;
22mod worker;
23
24pub use builder::Builder;
25pub use runtime::{LevelRuntime, LevelRuntimeHandle};
26pub use worker::{LevelWorker, LevelWorkerHandle};
27
28pub use runtime::spawn_balanced;
29pub use runtime::spawn_on_each;
30pub use worker::spawn_local;