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