hiver_runtime/lib.rs
1//! Hiver Runtime - High-performance async runtime
2//! Hiver运行时 - 高性能异步运行时
3//!
4//! # Overview / 概述
5//!
6//! `hiver-runtime` provides a high-performance async runtime based on io-uring
7//! with thread-per-core architecture for maximum scalability.
8//!
9//! `hiver-runtime` 提供基于io-uring的高性能异步运行时,采用thread-per-core架构
10//! 以实现最大可扩展性。
11//!
12//! # Features / 功能
13//!
14//! - io-uring based I/O (Linux) / 基于io-uring的I/O(Linux)
15//! - epoll/kqueue fallback / epoll/kqueue回退支持
16//! - Thread-per-core scheduler / Thread-per-core调度器
17//! - Timer wheel for efficient timers / 高效定时器的时间轮
18//! - Zero-copy I/O primitives / 零拷贝I/O原语
19//!
20//! # Example / 示例
21//!
22//! ```rust,no_run,ignore
23//! use hiver_runtime::Runtime;
24//!
25//! fn main() -> std::io::Result<()> {
26//! let runtime = Runtime::new()?;
27//! runtime.block_on(async {
28//! println!("Hello, Hiver!");
29//! });
30//! Ok(())
31//! }
32//! ```
33
34#![warn(missing_docs)]
35#![warn(unreachable_pub)]
36#![cfg_attr(docsrs, feature(doc_cfg))]
37// Allow unsafe operations in unsafe functions for Rust 2024 edition compatibility
38// 允许unsafe函数中的unsafe操作以兼容Rust 2024版本
39#![expect(unsafe_op_in_unsafe_fn)]
40// Allow unsafe code - runtime requires unsafe for low-level system operations
41// 允许unsafe代码 - 运行时需要unsafe进行底层系统操作
42#![allow(unsafe_code)]
43// Runtime-specific allowances: unwrap on mutex locks is acceptable as poisoning
44// is handled at a higher level, and integer casts are necessary for FFI.
45// 运行时特定允许:mutex上的unwrap是可接受的,因为中毒在更高层处理,
46// 且整数转换对于FFI是必要的。
47#![allow(clippy::unwrap_used)]
48// Allow integer casts for FFI and system calls
49// 允许用于FFI和系统调用的整数转换
50#![allow(clippy::cast_possible_wrap)]
51#![allow(clippy::cast_possible_truncation)]
52#![allow(clippy::cast_sign_loss)]
53// Allow indexing - runtime code does bounds checking at higher levels
54// 允许索引 - 运行时代码在更高层进行边界检查
55#![allow(clippy::indexing_slicing)]
56// Allow doc_markdown - bilingual documentation may trigger false positives
57// 允许doc_markdown - 双语文档可能触发误报
58#![allow(clippy::doc_markdown)]
59// Allow additional lints for runtime code
60// 允许运行时代码的额外检查
61#![allow(clippy::ptr_arg)]
62#![allow(clippy::std_instead_of_core)]
63#![allow(clippy::manual_is_power_of_two)]
64#![allow(clippy::uninlined_format_args)]
65#![allow(clippy::used_underscore_binding)]
66#![allow(clippy::deref_by_slicing)]
67#![allow(clippy::redundant_closure)]
68#![allow(clippy::borrow_as_ptr)]
69#![allow(clippy::ref_as_ptr)]
70#![allow(clippy::ptr_as_ptr)]
71
72// Public modules / 公共模块
73pub mod channel;
74pub mod driver;
75pub mod io;
76pub mod runtime;
77pub mod scheduler;
78pub mod select;
79pub mod task;
80pub mod time;
81
82// Re-exports / 重新导出
83pub use channel::{Receiver, RecvError, SendError, Sender, bounded, unbounded};
84pub use driver::{Driver, DriverConfig, DriverConfigBuilder, DriverFactory, DriverType};
85pub use runtime::{Runtime, RuntimeBuilder, RuntimeConfig};
86pub use scheduler::{
87 Scheduler, SchedulerConfig, SchedulerHandle, WorkStealingConfig, WorkStealingHandle,
88 WorkStealingScheduler, gen_task_id,
89};
90pub use select::{
91 SelectMultiple, SelectMultipleOutput, SelectTwo, SelectTwoOutput, select_multiple, select_two,
92};
93pub use task::{JoinError, JoinHandle, spawn};
94pub use time::{Duration, Instant, sleep, sleep_until};