用 Rust 来诠释 Epoll, Kqueue 和 IOCP
这其实是一本书,旨在说明 Epoll,Kqueue 和 IOCP 的工作原理,我们可以将其用于高效率、高性能的 I/O。其中一些实现将会使用 rust,原文地址:https://cfsamsonbooks.gitbook.io/epoll-kqueue-iocp-explained/
扩展阅读:Green Threads Explained in 200 Lines of Rust
reddit 上参与讨论:https://www.reddit.com/r/rust/comments/ephm4t/epoll_kqueue_and_iocp_explained_with_rust/
Deadpool
Deadpool
是一个死的简单异步池,用于任何类型的连接和对象。
Example
use async_trait::async_trait;
#[derive(Debug)]
enum Error { Fail }
struct Computer {}
struct Manager {}
type Pool = deadpool::managed::Pool<Computer, Error>;
impl Computer {
async fn get_answer(&self) -> i32 {
42
}
}
#[async_trait]
impl deadpool::managed::Manager<Computer, Error> for Manager {
async fn create(&self) -> Result&l