Skip to main content

ntex_rt/
lib.rs

1//! Single-threaded asynchronous runtime infrastructure for ntex.
2//!
3//! A [`System`] owns the runtime configuration and coordinates one or more
4//! [`Arbiter`] execution threads. Each arbiter runs local futures on its own
5//! thread, allowing tasks to use types that are not `Send`.
6//!
7//! Use [`System::build()`] to configure a system, [`spawn()`] to start a local
8//! task, and [`spawn_blocking()`] for blocking work.
9//!
10//! Runtime backends are selected with Cargo features:
11//!
12//! - no runtime feature uses the native ntex runtime
13//! - `tokio` uses the Tokio-based runtime adapter
14//! - `compio` uses the Compio-based runtime adapter
15#![deny(clippy::pedantic)]
16#![allow(
17    clippy::missing_errors_doc,
18    clippy::missing_fields_in_debug,
19    clippy::must_use_candidate
20)]
21
22mod arbiter;
23mod builder;
24mod busy;
25#[cfg(target_os = "linux")]
26mod capture;
27mod driver;
28mod handle;
29mod metrics;
30mod pool;
31pub mod signals;
32mod system;
33mod task;
34#[cfg(test)]
35mod testing;
36mod watchdog;
37
38mod rt;
39pub mod rt_default;
40
41#[cfg(feature = "compio")]
42pub mod rt_compio;
43#[cfg(feature = "tokio")]
44pub mod rt_tokio;
45
46pub use self::arbiter::{Arbiter, get_item, remove_all_items, set_item, with_item};
47pub use self::builder::{Builder, SystemRunner};
48pub use self::driver::{BlockFuture, Driver, DriverType, Notify, PollResult, Runner};
49pub use self::metrics::{HISTOGRAM_BUCKETS, Histogram, LatencyMetrics};
50pub use self::pool::{BlockingError, BlockingResult, PoolMetrics, ThreadPool, spawn_blocking};
51pub use self::rt::{Runtime, RuntimeBuilder};
52pub use self::system::{Id, PingRecord, System};
53pub use self::task::{task_callbacks, task_opt_callbacks};
54
55#[cfg(feature = "tokio")]
56pub use self::rt_tokio::*;
57
58#[cfg(all(feature = "compio", not(feature = "tokio")))]
59pub use self::rt_compio::*;
60
61#[cfg(all(not(feature = "tokio"), not(feature = "compio")))]
62pub use self::rt_default::*;
63
64pub(crate) type HashMap<K, V> = std::collections::HashMap<K, V, foldhash::fast::RandomState>;