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;
24#[cfg(target_os = "linux")]
25mod capture;
26mod driver;
27mod handle;
28mod pool;
29pub mod signals;
30mod system;
31mod task;
32#[cfg(test)]
33mod testing;
34
35mod rt;
36pub mod rt_default;
37
38#[cfg(feature = "compio")]
39pub mod rt_compio;
40#[cfg(feature = "tokio")]
41pub mod rt_tokio;
42
43pub use self::arbiter::{Arbiter, get_item, remove_all_items, set_item, with_item};
44pub use self::builder::{Builder, SystemRunner};
45pub use self::driver::{BlockFuture, Driver, DriverType, Notify, PollResult, Runner};
46pub use self::pool::{BlockingError, BlockingResult, ThreadPool, spawn_blocking};
47pub use self::rt::{Runtime, RuntimeBuilder};
48pub use self::system::{Id, PingRecord, System};
49pub use self::task::{task_callbacks, task_opt_callbacks};
50
51#[cfg(feature = "tokio")]
52pub use self::rt_tokio::*;
53
54#[cfg(all(feature = "compio", not(feature = "tokio")))]
55pub use self::rt_compio::*;
56
57#[cfg(all(not(feature = "tokio"), not(feature = "compio")))]
58pub use self::rt_default::*;
59
60pub(crate) type HashMap<K, V> = std::collections::HashMap<K, V, foldhash::fast::RandomState>;
61pub(crate) type HashSet<V> = std::collections::HashSet<V, foldhash::fast::RandomState>;