百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

compio

> 编程语言
开源

每个核心一个线程的异步 Rust 运行时,支持 IOCP/io_uring/polling。

1.8K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

每个核心一个线程的异步 Rust 运行时,支持 IOCP/io_uring/polling。

--- # Compio 一个基于 IOCP/io_uring/polling 的每核一个线程的 Rust 运行时,灵感来自 monoio。 ## 快速入门 将 compio 添加为依赖项: bash cargo add compio --features macros,fs 然后使用提供的高级 API 执行文件系统和网络 IO: ```rust use compio::{fs::File, io::AsyncReadAtExt};

#[compio::main] async fn main() { let file = File::open("Cargo.toml").await.unwrap(); let (read, buffer) = file.read_to_end_at(Vec::with_capacity(1024), 0).await.unwrap(); assert_eq!(read, buffer.len()); let buffer = String::from_utf8(buffer).unwrap(); println!("{}", buffer); } 也可以手动使用低级驱动(无异步执行器的主动程序)。请参阅 [`driver` 示例](./compio/examples/driver.rs)。 ## 可观察性 `console` 功能使运行时发出 [`tracing`] 跨程序和事件, `tokio-console` 可以消费这些信息,因此可以使用 `compio` 应用程序进行检查:bash cargo add compio --features console cargo add console-subscriber toml

.cargo/config.toml

console-subscriber refuses to run unless the runtime is known to be

instrumented; this is the escape hatch it provides for runtimes other than

tokio.

rustflags = ["--cfg", "console_without_tokio_unstable"] rust console_subscriber::init(); compio::runtime::Runtime::new().unwrap().block_on(async { // ... });


然后运行 `tokio-console` 以监视任务、轮询时间和唤醒器活动。[`console` 模块文档](https://docs.rs/compio-runtime/latest/compio_runtime/console/) 说明了哪些内容会被报告,哪些内容不会被报告。[`console` 示例](./compio/examples/console.rs) 在分派器上运行一个回显服务器,这样控制台可以显示每个核心线程的任务,并显示在它发出警告的错误任务旁边。它会在命令行上传递 cfg:

[build]
[`tracing`]: https://docs.rs/tracing
[`tokio-console`]: https://github.com/tokio-rs/console

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言